Commit Graph

40 Commits

Author SHA1 Message Date
Zoltan Somogyi
eeb69f14ba Use explicit streams in browser/*.m.
browser/browse.m:
browser/browser_info.m:
browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_oracle.m:
browser/declarative_user.m:
browser/diff.m:
browser/help.m:
browser/interactive_query.m:
browser/parse.m:
browser/util.m:
    Replace implicit streams with explicit streams.

    Shorten lines longer than 79 chars.

    In some places, simplify some code, often using constructs such as
    string.format that either did not exist or were too expensive to use
    when the original code was written.

    In some places, change predicate names that were not meaningful
    without module qualification by *including* the module qualification
    in the name (e.g. init -> browser_info_init).

    In some places, add XXXs.

    In browser_info.m, make the output stream *part* of the debugger type,
    because without this, having the debugger type belong to the stream
    typeclass does NOT make sense. (The typeclass instance for debugger
    used to always write to the current output stream, which this diff
    is replacing with the use of explicitly specified streams.)

    In browse.m, consistently put stream arguments before other arguments.

    In browse.m, when exporting Mercury predicates to C, export them
    under names with the standard ML_BROWSE_ prefix, NOT under the name
    of a *different* predicate with that prefix.

    In diff.m, eliminate an unnecessary difference between what we print
    when the difference between two terms is at the root, vs what we print
    when the difference between two terms is lower down.

    In interactive_query.m, when trying to write a program out to a file,
    do NOT write the program to the current output stream if we cannot open
    the file, since that would accomplish nothing useful.

    Also in interactive_query.m, cleanup .dylib instead of .so on MacOS.

    In util.m, delete some unused predicates.

    In collect_lib.m, document why some code is not worth updating.

    In declarative_oracle.m, rename predicates with previously-ambiguous
    names.

browser/MDBFLAGS.in:
    Specify --warn-implicit-stream-calls for all Mercury modules
    in the browser directory from now.

trace/mercury_trace_browse.c:
trace/mercury_trace_cmd_browsing.c:
ssdb/ssdb.m:
    Conform to the changes in browser/*.m.

tests/debugger/queens.{exp,exp2}:
    Expect the extra output from browser/diff.m.
2021-03-05 22:54:28 +11:00
Zoltan Somogyi
59b11f84ce Update the debugger test directory.
Replace __ with . as the module qualifier symbol.

Replace references to io.state with just io.

Replace DCGs with state variables.

Replace (C->T;E) syntax for if-then-elses with (if C then T else E) syntax.

Replace if-then-elses with switches when possible and where this does not
affect what is being tested.

Replace separate pred and mode declarations with predmode declarations.

Put predicate and function declarations just before the definition
of the predicate or function.

Delete unneeded module qualifications on predicate and function declarations
and definitions.

Update .exp files (and if needed, .inp files) for the line number changes
that result from the above.

For tests that have more than one .exp file and where one of those files
is affected by the above, add a section to the source file header that says
which .exp file is for what grade, with XXXs for the (as yet) unknown parts.
2018-08-28 21:20:59 +10:00
Zoltan Somogyi
33eb3028f5 Clean up the tests in half the test directories.
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the debugger tests,
    specify the new line numbers in .inp files and expect them in .exp files.
2015-02-14 20:14:03 +11:00
Zoltan Somogyi
f51d94e054 Provide support for list syntax and quoted function symbols in the terms
Estimated hours taken: 6
Branches: main

Provide support for list syntax and quoted function symbols in the terms
that appear in breakpoint conditions.

runtime/mercury_trace_term.[ch]:
	Provide the new capability when creating terms from strings.

	Since with nonempty lists, the function symbol of the created term
	("[|]") does not appear in the original string, do not try to reuse
	the memory of the string for the memory of the function symbols;
	instead, make a copy of each function symbol as needed. This also
	makes the code simpler by avoiding the need to mangle the original
	string to null-terminate these function symbols.

	Add a mechanism for reporting the location and nature of syntax errors.

	Don't assume that the initial string has no spaces.

trace/mercury_trace_spy.[ch]:
	Don't record the strings from which the terms in breakpoint conditions
	came from, since function symbols' memory no longer comes from there,
	and thus we don't have to free them when the breakpoint is deleted.

trace/mercury_trace_cmd_breakpoint.c:
	Use the new mechanism for reporting the details of syntax errors in
	terms.

	Include spaces in the string from which terms are constructed
	at the points at which the user included spaces, since the absence
	of such spaces in any reports of syntax errors would be surprising.

	Delete the temporary memory for strings containing terms as soon
	as they have been used to construct their terms.

trace/mercury_trace_internal.c:
	Document a problem.

trace/Mmakefile:
	Rebuild this directory automatically if a few more headers in the
	runtime change.

doc/user_guide.texi:
	Document the new capability.

tests/debugger/queens.{inp,exp,exp2}:
	Test the new capability.
2007-06-15 08:26:47 +00:00
Zoltan Somogyi
0d6c3c9fdf Satisfy a request by Peter Ross: give mdb users the ability to specify
Estimated hours taken: 8
Branches: main

Satisfy a request by Peter Ross: give mdb users the ability to specify
exactly which events inside a procedure they want to put breakpoints on.
Amongst other things, this can make checking postconditions easier:
you can now put a conditional breakpoint on only the exit event.

runtime/mercury_stack_layout.h:
	Add to the exec trace part of proc layouts fields describing an array
	of the label layouts describing the events of the procedure. This is
	the most direct way to implement the new functionality. (In theory,
	we could search the data structures that map file names and line
	numbers to label layouts, but that would be complex, inefficient,
	and *error prone*.)

	To make room for the new fields, and to prepare for making the
	procedure body available to the deep profiler as well (which could
	use it to map execution frequencies of calls back to their location
	in the procedure body, and thus to things like the frequencies with
	which various switch arms are selected), move the procedure body
	of the execution-trace-specific part of the proc layout, and to
	where the deep profiler could in the future also get at it.

runtime/mercury_goto.h:
	Add macros for declaring more than one label layout structure at a
	time.

compiler/layout.m:
	Implement the changes in mercury_stack_layout.h in the compiler's
	data structures as well.

compiler/stack_layout.m:
	Conform to the changes in mercury_stack_layout.h.

	Turn some tuples into named types.

compiler/layout_out.m:
	Conform to the changes in mercury_stack_layout.h.

	Add a mechanism to declare the label layouts in the new array before
	referring to them, by generalizing some existing code. Make this code
	require that the label layouts we refer to via the macros in
	mercury_goto.h match the declarations generated by those macros,
	i.e. that they have information about variables (if debugging is
	enabled, they will).

compiler/opt_debug.m:
	Conform to the change to layout.m.

compiler/prog_rep.m:
	Make a predicate name more expressive.

trace/mercury_trace_cmd_breakpoint.c:
	Implement the new way of using the "break" command, which is
	to add a port name after the procedure specification.

	Register procedures at the start of the function implementing
	the "break" command, instead of "on demand", since all alternatives
	eventually do demand it.

	Write ambiguity reports wholly to mdb's stdout, instead of partially to
	stderr and partially to stdout.

trace/mercury_trace_spy.c:
	Print the port and the goal path for breakpoints on specific events.

	Make the invocation conditions left-aligned, not right-aligned.

doc/user_guide.texi:
	Document the new way of using the "break" command.

NEWS:
	Announce the new capability.

tests/queens.{inp,exp,exp2}:
	Add tests of the new capability.

tests/breakpoints.{exp,exp}:
tests/lval_desc_array.{exp,exp2}:
	Expect the new alignment of invocation conditions.
2007-06-12 06:06:35 +00:00
Zoltan Somogyi
04e76846e4 Replace names of the form "HeadVar__n" with meaningful names in a larger class
Estimated hours taken: 3
Branches: main

Replace names of the form "HeadVar__n" with meaningful names in a larger class
of cases than we do currently.

compiler/typecheck.m:
	Implement the change above.

compiler/clause_to_proc.m:
compiler/hlds_clauses.m:
compiler/simplify.m:
	Fix some minor issues I found while looking for the right piece of code
	to change.

tests/debugger/queens.{inp,exp,exp2}:
	Extend the input to the test case to print the names of the arguments
	of the nodiag predicate (whose head variables are now named "B" and
	"D", not HeadVar__1 and HeadVar__2).

	Expect fewer conjuncts in the top-level conjunction, since the
	unifications HeadVar__1 = B and HeadVar__2 = D can now be
	optimized away.

tests/debugger/higher_order.exp:
tests/debugger/synth_attr.exp:
tests/debugger/user_event.exp:
tests/debugger/user_event_shallow.exp:
	Update variable names and/or goal paths as for queens.

tests/debugger/higher_order.exp2:
	Document that this file is not currently used.
2007-04-26 09:10:47 +00:00
Zoltan Somogyi
8576975c4e Implement breakpoints on user events. Users may specify an event set,
Estimated hours taken: 20
Branches: main

Implement breakpoints on user events. Users may specify an event set,
an event name, both, or neither. Four forms of the mdb "break" command
create such breakpoints:

	break [the usual options] user_event <event_name>
	break [the usual options] user_event <event_set_name> <event_name>
	break [the usual options] user_event_set
	break [the usual options] user_event_set <event_set_name>

In addition, the command

	break [the usual options] user_event

is also accepted, as a synonym for

	break [the usual options] user_event_set

Since user events are not interface events or entry events, add a new, simple
ignore specification, which decrements the ignore count on every match of the
event.

Make the "break_print" mdb command consistent with the other command that
operates on existing breakpoints ("condition") by making it apply by default
to the most recently created breakpoint.

Make "condition" and "break_print" use the same option letter (-b) to introduce
the breakpoint number.

Fix a bug in the implementation of "break_print" that led to printing out
the selected variable, but not the selected *path* within the selected
variable. The reason was that we recorded what to print (variable spec plus
path) in a string, but that the process of using that record to print out
what was wanted destroyed the string (by putting a NULL between the variable
specification and the path), so that *later* uses of that string would find
an empty path. The fix is to record a var_spec/path pair in the print list.

Fix some slightly misleading output: when printing part of a variable, we
printed the name of the variable without any indication that the value printed
wasn't the whole value of the variable. We now print the path as well.

doc/user_guide.texi:
	Document the changes above.

	Document the usage "break_print [options] none", which we have always
	supported, but which was not documented.

runtime/mercury_stack_layout.h:
	Add a utility macro.

trace/mercury_trace.c:
	Fix a bug which left a variable uninitialized.

trace/mercury_trace_cmd_breakpoint.c:
	Implement the new command forms and options described above.

trace/mercury_trace_spy.[ch]:
	Implement data structures for keeping track of the new forms of
	breakpoints, and add the necessary functions for manipulating them.
	Update the function that checks whether the current event matches.
	Factor some common code out of that function, as well as out of the
	functions for adding new breakpoints.

	Change the print list data structure as described above.

	Add some utility functions.

	Add MR_ prefixes to the names of structure fields that previously
	lacked them.

trace/mercury_trace_cmd_misc.c:
	Handle the new breakpoint types.

trace/mercury_trace_tables.c:
trace/mercury_trace_internal.c:
	We used to parse the event set descriptions in module layout structures
	when the debugger was initialized (in mercury_trace_internal.c).
	However, we delay registering all the modules until this is needed,
	so at that time we don't yet *have* the list of module layout
	structures, so we used to parse nothing. This diff moves the code
	for doing the parsing to the time when the module layout structures
	are registered (in mercury_trace_tables.c).

	Don't test whether the module layout structure contains the fields
	for user event descriptions, since that diff has been installed on
	all our systems weeks ago.

trace/mercury_trace_internal.c:
	Conform to the new print list structure.

trace/mercury_trace_vars.[ch]:
	Print any selected path together with a variable name when printing a
	value. (This is the last bug fix mentioned at the top.)

	Export a function for use in mercury_trace_internal.c.

	Add some utility functions.

	Improve some error messages.

trace/mercury_trace_tables.h:
	Add a const qualifier.

tests/debugger/user_event.{inp,exp}:
	Extend this test case to test the new functionality.

tests/debugger/breakpoints.{inp,exp,exp2}:
	Conform to the change to the break_print command.

tests/queens.{inp,exp}:
	Change the input to test the bug fix to the break_print command,
	and the expected output.

tests/browser_test.exp:
tests/field_names.exp:
	Conform to the fact that we now print paths after variables names.
2007-01-19 04:42:52 +00:00
Zoltan Somogyi
2bada9761f Eliminate some code duplication by unifying the two goal_path types have had
Estimated hours taken: 2
Branches: main

Eliminate some code duplication by unifying the two goal_path types have had
until now: one in mdbcomp/program_representation.m and compiler/hlds_goal.m,
which differed in only one detail (whether we record the total number of arms
in a switch). The new type is in program_representation.m, but with the
definition from goal_path.m.

Add a "step_" prefix to the function symbols of the goal_path_step type,
to avoid ambiguity with the hlds goals the steps describe.

Turn the predicates operating on goal_paths into functions for greater
convenience of use.

mdbcomp/program_representation.m:
compiler/hlds_goal.m:
	Make the change described above.

browser/*.m:
compiler/*.m:
mdbcomp/*.m:
slice/*.m:
	Conform to the change above.

tests/debugger/*.exp:
	Expect the extra information now available for goal path steps
	describing switches.
2007-01-06 10:56:27 +00:00
Zoltan Somogyi
25b8b1abc3 Fix several performance bugs that showed up when the compiler was invoked on
Estimated hours taken: 20
Branches: main

Fix several performance bugs that showed up when the compiler was invoked on
Douglas Auclair's training_cars example. Also fix some minor problems that
made it harder to find the information needed to localize those problems.

training_cars.m is hard to compile quickly because it is big in two dimensions:
it has lots of clauses, and each clause has big terms.

My laptop still tries to swap itself to death on the full version of
training_cars.m (it has only 512 Mb), but the compiler now works fine
on a version containing about 20% of its clauses, whereas previously
it couldn't compile it at all.

In most cases, the changes convert N^2 algorithms to NlogN algorithms.
They probably have higher constant factors and may yield small slowdowns
for small N, but this is probably not noticeable. Avoiding bad worst case
behavior is more important.

compiler/superhomogeneous.m:
	Record the number of goals inserted in each goal being converted
	to superhomogeneous form. If this exceeds a threshold, wrap a
	from_ground_term scope around it.

	Put the predicates into a more cohesive sequence.

compiler/field_access.m:
	Work with the code in superhomogeneous to record the number of inserted
	goals. Reorder the arguments of some performances to be consistent
	with the predicates in superhomogeneous.m.

compiler/modes.m:
	Use the from_ground_term scope to reverse the list of inserted
	unifications if necessary. It is much more efficient to do this here
	than to let it happen by sequences of delays and wakeups. That would
	have quadratic complexity; this is linear.

	This is what I originally introduced from_ground_term scopes for.
	Then, the overhead was too high, because I added one scope per function
	symbol. This version should be fine, since there is at most one scope
	added per argument of an atom (clause head or call).

compiler/modes.m:
compiler/unique_modes.m:
	When we are processing goals inside a from_ground_term scope, record
	this fact.

compiler/mode_info.m:
	Make it possible to record this fact.

compiler/modecheck_unify.m:
	When we are inside a from_ground_term scope, don't try to update the
	insts of vars on the right hand sides of construction unifications.
	Since these variables came from expansion to superhomogeneous form,
	those variables won't occur in any following code, so updating their
	state is useless, and the algorithm we used to do so is linear in the
	size of the inst. Since the size of an inst of a variable that results
	from superhomogeneous expansion is itself on average proportional to
	the size of the original term, this change turns a quadratic algorithm
	into a linear one.

compiler/inst_match.m:
	Use balanced trees instead of ordered lists to represents sets of
	expansions, since these sets can be large.

	Note an opportunity for further improvement.

compiler/inst_util.m:
	Note another opportunity for further improvement.

compiler/instmap.m:
	Rename several predicates to avoid ambiguities.

compiler/cse_detection.m:
	We used to print statistics for the processing of each procedure
	without saying which procedure it is for; fix this.

compiler/switch_detection.m:
	Don't print progress messages for predicates with no procedures,
	since they would be misleading.

compiler/higher_order.m:
	Change an algorithm that was quadratic in the number of arms
	for merging the information from the different arms of disjunctions
	and switches to an NlogN algorithm.

	Change the algorithm for merging the info from two branches
	that quadratic in the number of variables per arm to an NlogN
	algorithm.

	Changed some type equivalences to notag types to aid robustness.

compiler/quantification.m:
	Rename several predicates to avoid ambiguities.

	The sets of variables in different arms of disjunctions and switches
	tend to have relatively small intersections. Yet the algorithms we
	used to compute the set of variables free in the disjunction or switch
	included the variables from the already processed arms in the sets
	being accumulated when processing later arms, leading to the quadratic
	behavior. This diff changes the algorithm to process each arm
	independently, and then use a more balanced algorithm to summarize
	the result.

	Specialize the predicates that compute sets of free vars in various
	HLDS fragments to work either with ordinary_nonlocals or
	code_gen_nonlocals without making the same decision repeatedly.

	Move some code out of large predicates into predicates of their own.

compiler/Mercury.options:
	Specify the compiler option that can exploit this specialization
	to make the code run faster.

compiler/simplify.m:
	Use a more efficient data structure for recording the parameters
	of an invocation of simplification.

	Change some predicate names and function symbol names to avoid
	ambiguity.

compiler/common.m:
compiler/deforest.m:
compiler/deforest.m:
compiler/make_hlds_warn.m:
compiler/mercury_compile.m:
compiler/pd_util.m:
compiler/stack_opt.m:
compiler/term_constr_build.m:
	Conform to the changes in simplify.m and/or instmap.m.

compiler/mercury_compile.m:
	Fix a bug in progress messages for polymorphism.m.

compiler/equiv_type_hlds.m:
	Most of the time, substitutions inside insts have no effect, because
	very few insts include any reference to a types. Instead of the old
	approach of building new insts and then throwing them away if they
	are the same as the old ones, don't build new insts at all if the
	old inst contains no types.

compiler/common.m:
	Change some predicate names to make them clearer.

compiler/hlds_clauses.m:
	Record the number of clauses so far, to allow a more informative
	progress message to be printed.

compiler/add_clause.m:
	Print this more informative progress message.

	Conform to the changes in superhomogeneous.m.

compiler/code_gen.m:
	Use the context of the predicate's first clause (which will be the
	context of the first clause head) as the context of the predicate's
	interface events. Unlike the context of the body goal, this won't
	be affected by program transformations such as wrapping a
	from_ground_term scope around some goals. It is better for users
	anyway, since the old policy lead to contexts in the middle of
	procedure bodies if the top level goal was a disjunction, switch or
	if-then-else.

tests/debugger/*.exp:
	Update the expected outputs to conform to the change to code_gen.m.
2006-03-29 00:57:46 +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
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
d03ce7dbc0 Fix some bugs in my previous diff that optimized away stack slots storing
Estimated hours taken: 8
Branches: main

Fix some bugs in my previous diff that optimized away stack slots storing
dummy values that manifested themselves as warnings from the C compiler
about integers too big to fit into 8 or 16 bits being implicitly truncated.
They did not lead to the failure of any test case, since it doesn't matter
whether the debugger gets the values it ignores (I/O states or stores)
from valid stack slots or not.

When generating RTTI for gc and the debugger, the compiler had three places
that generated references to stack slots: the return sites of calls, resume
points, and trace events. The previous diff updated only the first of these.
This diff updates the other two, and ensures there are no more.

Since the debugger needs to know whether a procedure has a pair of I/O state
arguments (e.g. when performing a retry), we add a field to proc layouts
to hold this information.

runtime/mercury_grade.h:
	Increment the debug grade runtime compatibility version number
	to reflect the change in layout structures.

runtime/mercury_stack_layout.h:
	Add an extra field to proc layouts to specify flags. At the moment,
	the only flag says whether the procedure has a pair of I/O state
	arguments.

	Add an extra field to proc layouts to specify the trace level of a
	procedure. This used to be the same as the module's trace level,
	but one of my bug fixes a couple of months ago broke that link.
	We don't yet use this field, but it makes sense to do it at the same
	time as the increment of the compatibility version number.

compiler/continuation_info.m:
	Attach to every description of a live value a description of where
	in the compiler that description was created.

	Rename the type involved to avoid an ambiguity.

	Ignore dummy types when generating resume layouts.

	Add some sanity checks.

	Add new fields to the continuation_info data structure to allow
	stack_layout.m to fill in the new fields in proc layout structures.

compiler/trace.m:
	Do not generate references to dummy values at trace events,
	except at call ports. At those ports, all live variables should
	be in registers.

compiler/stack_layout.m:
	Make the check for whether a value fits into an unsigned 8 bit value
	a direct rather than an indirect one. The indirect one assumed that
	stack slot numbers are all positive, which is now a bad assumption.

	Check for negative stack slot numbers in all RTTI stack slot
	descriptions.

	Fill in the two new slots in proc layout structures.

compiler/layout.m:
	Reserve space for the two new slots in proc layout structures.

compiler/layout_out.m:
	Output the two new slots in proc layout structures.

compiler/code_gen.m:
	Preserve the information needed by stack_layout.m for the two new
	fields.

compiler/llds_out.m:
	Add some code that ensures that we never output an integer constant
	that doesn't fit into the range of its type. Since this code is
	executed many millions of times, it is designed to be enabled only
	when the checking is manually enabled. It is normally off, but I got
	a clean bootcheck in the debug grade (which is the best stress test)
	with it enabled.

compiler/trace_params.m:
	Update a comment.

compiler/code_info.m:
	Export a function for use by trace.m.

compiler/hlds_pred.m:
	Export a predicate for use by stack_layout.m.

compiler/Mercury.options:
	Enable inlining for llds_out.m, to get rid of the sanity checking
	overhead if it is not enabled.

tests/debugger/completion.exp*:
tests/debugger/interpreter.exp*:
tests/debugger/multi_parameter.exp*:
tests/debugger/queens.exp*:
tests/debugger/print_goal.exp*:
tests/debugger/tabled_read.exp*:
tests/debugger/tabled_read_decl.exp*:
tests/debugger/declarative/io_stream_test.exp*:
tests/debugger/declarative/tabled_read_decl.exp*:
	Update these expected output files to not expect dummy values that
	aren't kept anymore.
2004-11-19 05:46:25 +00:00
Ian MacLarty
cab3c62fe7 Remove call depth numbers from standardized event printing.
Estimated hours taken: 2
Branches: main

Remove call depth numbers from standardized event printing.  This will make
maintaining the debugger test cases easier since a lot of the expected outputs
differ only in the call depth of their events, because of deep tracing of the
standard library in the decldebug grade.

Not all the debugger tests are run with standardized event printing, so
printing of call depths will still be exercised.

tests/debugger/breakpoints.exp
tests/debugger/breakpoints.exp2
tests/debugger/browser_test.exp
tests/debugger/exception_cmd.exp
tests/debugger/exception_cmd.exp2
tests/debugger/exception_cmd.exp3
tests/debugger/exception_value.exp
tests/debugger/exception_value.exp2
tests/debugger/exception_vars.exp
tests/debugger/existential_type_classes.exp
tests/debugger/existential_type_classes.exp2
tests/debugger/exported_eqv_type.exp
tests/debugger/higher_order.exp
tests/debugger/interpreter.exp2
tests/debugger/lambda_expr.exp
tests/debugger/loopcheck.exp3
tests/debugger/loopcheck.inp2
tests/debugger/nondet_stack.exp
tests/debugger/nondet_stack.exp2
tests/debugger/polymorphic_output.exp
tests/debugger/polymorphic_output.exp2
tests/debugger/polymorphic_output.exp3
tests/debugger/print_goal.exp
tests/debugger/print_table.exp
tests/debugger/queens.exp
tests/debugger/queens.exp2
tests/debugger/resume_typeinfos.exp
tests/debugger/retry.exp
tests/debugger/retry.exp2
tests/debugger/tabled_read.exp
tests/debugger/tabled_read_decl.exp
tests/debugger/tabled_read_unitize.exp
tests/debugger/type_desc_test.exp
tests/debugger/declarative/aadebug.exp
tests/debugger/declarative/app.exp
tests/debugger/declarative/args.exp
tests/debugger/declarative/big.exp
tests/debugger/declarative/filter.exp
tests/debugger/declarative/if_then_else.exp
tests/debugger/declarative/input_term_dep.exp
tests/debugger/declarative/io_stream_test.exp
tests/debugger/declarative/io_stream_test.exp2
tests/debugger/declarative/output_term_dep.exp
tests/debugger/declarative/propositional.exp
tests/debugger/declarative/remember_modes.exp
tests/debugger/declarative/special_term_dep.exp
tests/debugger/declarative/tabled_read_decl.exp
tests/debugger/declarative/trust.exp
	Remove call depth numbers from output run with standardized event
	printing.

trace/mercury_trace_internal.c
	Remove call depth from standardized event printing.
2004-11-16 00:16:44 +00:00
Zoltan Somogyi
1f49c5b8ac Update line numbers after my change to the source file.
Estimated hours taken: 0.2
Branches: main

tests/debugger/queens.{inp,exp}:
	Update line numbers after my change to the source file.
2003-06-20 12:33:55 +00:00
Zoltan Somogyi
05aead3983 *** empty log message *** 2003-04-16 12:37:47 +00:00
Ralph Becket
a8ffd3680c Change the compiler and tools so that .' and not :' is now used as the
Estimated hours taken: 14
Branches: main

Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.

Infix `.' now has associativity yfx and priority 10.

NEWS:
	Report the change.

configure.in:
	Amend the test for an up-to-date Mercury compiler to check whether
	it recognises `.' as a module qualifier.

compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
	Change `:' to `.' as module separator for output.

compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
	As above.
	Fixed a bug where `.' was not being recognised as a module separator.

doc/reference_manual.texi:
	Report the change.

library/term_io.m:
	Ensure that infix `.' is written without surrounding spaces.

tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
	Test case added.
2003-01-17 05:57:20 +00:00
Zoltan Somogyi
5345fa4643 Fix (most of) the expected outputs of the debugger test cases after my recent
Estimated hours taken: 2
Branches: main

Fix (most of) the expected outputs of the debugger test cases after my recent
changes. In some cases, this involved modifying the input scripts to make tests
less dependent on event numbers.

tests/debugger/Mmakefile:
	Use MDB_STD instead of MDB for more test cases than before.

	Disable the output_term_dep test case, since it doesn't actually test
	anything that the other test cases don't test, and it prints so many
	events that its .exp files depend on event numbers far too much.

tests/debugger/*.exp*:
tests/debugger/*.inp:
	Update expected outputs, and in some cases, the inputs.
2002-09-13 03:37:45 +00:00
Zoltan Somogyi
5f20c37b7a Add a mechanism for standardizing the event and call sequence numbers in
Estimated hours taken: 4
Branches: main

Add a mechanism for standardizing the event and call sequence numbers in
debugger output. The mechanism is a global flag whose value is set from
MERCURY_OPTIONS. It is intended to be used only in our own internal testing.

runtime/mercury_trace_base.[ch]:
	Define the global, MR_standardize_event_details.

	Move the documentation of several globals from the .c to the .h file,
	since that is where their users will look. Put those globals in a
	consistent order.

	Add functions for standardizing event and call sequence numbers,
	and use them when printing event details.

runtime/mercury_wrapper.c:
	Set MR_standardize_event_details when given the option -de.

runtime/mercury_stack_trace.c:
library/exception.m:
trace/mercury_trace_internal.m:
	Respect MR_standardize_event_details.

tests/Mmake.common:
	Define the make variable MDB_STD, which is like MDB except it also
	puts -de in MERCURY_OPTIONS.

tests/debugger/Mmakefile:
	Use MDB_STD instead of MDB for test cases that can benefit from
	standardizing event and call sequence numbers.

	Put the rules for the test cases in alphabetical order.

tests/debugger/*.exp*:
	Update expected outputs after this change.
2002-09-11 07:20:31 +00:00
Simon Taylor
07c0cf8ba6 Improve variable naming in the debugger. Where possible, use
Estimated hours taken: 10
Branches: main

Improve variable naming in the debugger. Where possible, use
the user's argument names rather than `HeadVar__N'.

compiler/clause_to_proc.m:
	Use the user's names for the arguments of
	`:- pragma foreign_proc' procedures.

compiler/simplify.m:
	When performing excess assignment elimination with `--trace deep',
	don't replace a variable with a meaningful name with `HeadVar__N'
	or an unnamed variable.

compiler/trace_params.m:
	Add a predicate `trace_level_needs_meaningful_var_names'
	for use by simplify.m.

compiler/typecheck.m:
	For predicates with a single clause, attempt to replace the
	`HeadVar__N' variables with the user's original head variables.

trace/mercury_trace_declarative.c:
trace/mercury_trace_vars.c:
	Don't assume head variables have names of the form `HeadVar__N'.

	Print the argument number when printing the names of
	head variables.

tests/debugger/browser_test.inp:
tests/debugger/completion.inp:
	Change names of variables in `print' commands.

tests/debugger/*.exp:
tests/debugger/*.exp2:
tests/debugger/declarative/dependency.exp:
tests/invalid/aditi_errors.err_exp:
tests/invalid/mode_inf.err_exp:
tests/invalid/record_syntax_errors.err_exp:
	Update expected output.
2002-06-05 16:41:31 +00:00
Zoltan Somogyi
7570fac833 Some of fjh's review comments on my change to enable the deconstruction and
Estimated hours taken: 3
Branches: main

Some of fjh's review comments on my change to enable the deconstruction and
printing of igher order terms arrived after I committed that change. This diff
addresses those comments.

library/deconstruct.m:
	Specify what happens with include_details_cc.


runtime/mercury_deconstruct.c:
	Add a second argument to MR_expand_type_name that specifies whether
	the name of the type specified by the first argument should be wrapped
	in <<>> or not.

runtime/mercury_ml_expand_body.h:
 	Handle type_ctor_infos by returning the type name (without <<>>) as
	a zero-arity functor.

runtime/mercury_type_info.[ch]:
	Delete the code for expanding out type_ctor_info "equivalences", since
	as Fergus pointed out the concepts doesn't make sense.

trace/mercury_trace_internal.c:
	When the user turns the printing of optional values off or on,
	make that change take effect immediately.

tests/debugger/queens.{inp,exp*}:
	Test the immediate nature of the print_optionals command.

NEWS:
	Announce the print_optionals command.
2002-03-12 03:40:42 +00:00
Simon Taylor
5544aed7ff Change the list constructor from ./2' to [|]/2'. `./2' will
Estimated hours taken: 3
Branches: main

Change the list constructor from `./2' to `[|]/2'. `./2' will
eventually become the module qualification operator.

library/parser.m:
library/io.m:
library/sparse_bitset.m:
library/std_util.m:
library/term_io.m:
compiler/mercury_to_mercury.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
browser/interactive_query.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/morphine/source/generate_call_site_cov.m:
extras/xml/xml.encoding.m:
samples/muz/higher_order.m:
tests/debugger/declarative/app.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/ground_dd.m:
tests/hard_coded/split_c_files.m:
	Change all references to `./2' to use `[|]/2' instead.

compiler/typecheck.m:
	Handle `./2' as a special case in `report_error_undef_cons'.

	Warn about module list not being imported if `[|]/2' is undefined.

compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
	Add name conversions for `[|]' (f_cons) and `[]' (f_nil).

NEWS:
doc/reference_manual.texi:
w3/tutorial/lists-n-things.m4:
	Document the changes.

tests/debugger/{,declarative}/*.exp*:
	Update test case results. For some tests the output changed
	because they output lists in the non-pretty format. For others,
	the output changed because the alphabetical ordering of the
	constructors of type `list/1' changed, so the numbering of
	the switch branches in the goal paths changed.
2001-09-25 09:37:12 +00:00
Zoltan Somogyi
b0512b72c6 Fix several bugs in retry.
Estimated hours taken: 8

Fix several bugs in retry.

trace/mercury_trace.c:
	Fix three bugs reported by Fergus in the behavior of the mdb retry
	command.

	Catch the case where the retry command tries to retry a call that
	would be an ancestor of main.

	Catch the case where the retry command tries to retry a call that
	is in shallow traced region of the computation tree.

	Don't abort if the retried call is missing an I/O state argument
	and relevant procedure was compiled without --trace-table-io; just
	ask the user whether they want to proceed with the retry.

	Add some conditionally compiled debugging code.

trace/mercury_trace.c:
trace/mercury_trace_spy.c:
	Fix a bug unrelated to retry that was detected by new additions
	to the test cases: spy points were being printed after being deleted.
	Deletion was releasing some strings (filenames) in some spy points,
	leading to those filename being printed as garbage. We now print the
	spy points before deleting them. This required moving the code
	for marking spy points as deleted from mercury_trace_spy.c to
	mercury_trace.c.

compiler/trace.m:
	Fix a bug that caused the debugger to core dump when given a retry
	command that went across a shallow traced region of the program.
	(This bug was exposed when I fixed the second bug reported by Fergus.)
	A procedure that lives on the det stack that nevertheless pushes
	temporary frames onto the nondet stack should save the original value
	of maxfr on procedure entry even if it is shallow traced and from_full
	is false, since the debugger will need to restore the value of maxfr
	during retry.

tests/debugger/queens.{inp,exp,exp2}:
	Test how mdb handles trying to retry an ancestor of main.

	Test how mdb handles a retry with a missing I/O state argument.

tests/debugger/all_solutions.{m,inp,exp,exp2}:
	New test case. The code is a copy of samples/solutions/all_solutions.m.
	Its input script tests retry into and across a shallow traced region
	(inside std_util:solutions).
2000-12-18 05:16:59 +00:00
Zoltan Somogyi
fdccd65e30 The debugger's retry command at the moment works only from a final port for
Estimated hours taken: 60

The debugger's retry command at the moment works only from a final port for
the call to be retried, the reason being that the RTTI does not have the
information required to make sure that the state of the stacks is reset
correctly. If you invoke retry from a non-final port, the current
implementation skips forward to a final port and then does the retry;
this does not work if you get a core dump or a infinite loop during the forward
skip. This change adds the required info to the RTTI and thus enables
direct retries from the middle of calls.

The information added has two components. First, if a procedure that lives on
the nondet stack allocates any temporary nondet stack frames, then it must
record the old value of maxfr in a stack slot so that retry can restore it.
Second, if a procedure is tabled, then it must record the call table tip node
corresponding to the actual input arguments, so we can reset this node to
uninitialized (if we don't, then the retried call will find the active call
marker and report an infinite loop error).

The support for retries across minimal model calls is not finished yet.
Finding out what the right thing to do in such cases is a research project,
one that cannot even be started until minimal model tabling works reliably
in the *absence* of retries. However, such retries do grossly wrong things
at the moment; this change is a definite improvement. It attempts to perform
the retry from the fail port, since that is the only time when the minimal
model tabling data structures are quiescent. The "fail" command I added to
the debugger command set to let this be done is not complete yet and is
therefore undocumented; the problem is that a call to a model_non predicate
in a committed choice context will not get to the fail port. I added goal paths
to return layouts so that we will eventually be able to tell when execution
leaves a committed choice context surrounding an ancestor of a model_non
predicate call, but this functionality is not yet implemented.

compiler/stack_layout.m:
	Generate the three new fields: the evaluation method, (maybe) the id
	of the stack slot containing the saved value of maxfr, and (maybe)
	the id of the stack slot containing the call table tip.

compiler/continuation_info.m:
	Record the information about the new fields for later use by
	stack_layout.m.

	Add a new field to record the goal path of calls for their return
	layouts.

	Fix a screwed comment for the continuation_info data structure.

compiler/llds.m:
	Add a new field to call() instructions to hold the goal path of the
	call.

	Add a utility function for use by trace.m.

compiler/call_gen.m:
	Fill in this new field.

compiler/trace.m:
compiler/live_vars.m:
	Reserve the fixed stack slot for the saved maxfr if necessary,
	and if the call table tip node is needed, make sure that the variable
	holding its address is allocated a low-numbered stack slot (otherwise,
	its number may not fit into the MR_int_least8_t field in the
	proc_layout).

compiler/trace.m:
	If necessary, fill in the saved maxfr slot.

	If necessary, initialize the call table tip slot.

compiler/hlds_goal.m:
	Add a goal feature which marks its goal as defining the variable
	representing the call table tip node.

	Add a field to the goal path step representing quantification;
	the field says whether the quantification changes the determinism of
	the goal (i.e. whether it cuts away solutions).

compiler/hlds_pred.m:
compiler/hlds_out.m:
	Add two fields to proc_infos which (a) record which variable, if any,
	holds the call table tip node, and (b) record whether the procedure's
	layout structure needs to reserve a slot for the saved value of maxfr.

compiler/table_gen.m:
	Put this feature on the appropriate goal.

	Also, rename a predicate to make it reflect its purpose better.

compiler/code_gen.m:
	Generate code to put the call table tip variable in its stack slot
	immediately after it has been generated.

	Add a sanity check to ensure that if a procedure that lives on the det
	stack can create a temporary nondet frame, and debugging is enabled,
	then it did have a stack slot reserved for the saved maxfr.

compiler/code_util.m:
	Add a predicate to make a conservative prediction of whether a
	procedure may allocate a temporary nondet stack frame. We cannot
	just generate the code and see, because the code generator needs to
	know which variables live in which stack slots, and we cannot decide
	that until we know whether we need a stack slot for the saved value of
	maxfr.

	Make an unrelated predicate semidet procedure use a det helper, in
	order to make it more robust in the face of changes to the HLDS
	(e.g. it was missing code for handling bi_implications).

compiler/code_info.m:
	Record whether a procedure has in fact created a temporary nondet stack
	frame.

compiler/handle_options.m:
	Disable hijacks if debugging is enabled. The code we now use to
	restore the stacks for direct retries works only if the retry does not
	"backtrack" over a hijacked nondet stack frame whose hijack has not
	been undone. Note that code compiled without debugging may still hijack
	nondet stack frames. Execution may reemerge from the nondebugged region
	in one of two ways. If the nondebugged code returns, then it will have
	undone hijack, and the retry code will work. If the nondebugged code
	calls debugged code, there will be a region on the stacks containing
	no debugging information, and the retry command will refuse to perform
	retries that go into or beyond this region. Both cases preserve
	correctness.

compiler/*.m:
	Trivial changes to conform to changes in data structures.

runtime/mercury_stack_layout.h:
	Add three new fields to proc layouts: the numbers of the stack slots
	(if any) storing the saved maxfr and the call table tip, and a
	representation of the procedure's evaluation method.

runtime/mercury_stack_trace.[ch]:
	Now that return layouts contain goal paths, print them in stack dumps
	only if the include_trace_data flag is set (in mdb, this requires the
	-d flag of the "stack" command).

	Pass this flag around directly, instead of encoding its value in
	the NULL vs non-NULL values of sp and curfr.

runtime/mercury_regorder.h:
	Provide a mechanism to access the values of the first few rN registers
	from a save area, for use in debugging low-level C code in the runtime
	and the trace directories.

trace/mercury_trace.[ch]:
	Reimplement MR_trace_retry to allow retries from the middle.
	If the stack segment being retried over contains minimal model
	procedures, we must still arrange to skip to the end of the retried
	call. If this call is a minimal model generator, skipping to just any
	final port is not sufficient to guarantee correctness on retry; to
	ensure that subgoal is complete, we must skip to a fail port.

trace/mercury_trace.[ch]:
trace/mercury_trace_internal.c:
	Implement a debugger command, "fail", which skips to the fail port or
	the exception port of the specified ancestor. Since procedures that are
	not model_non are not guaranteed to get to such a port, this
	command reports an error if the specified call is not model_non.
	Actually, even calls to model_non procedures may not get to the fail
	port, as explained above; this is why the command is not yet
	documented.

trace/mercury_trace.c:
trace/mercury_trace_util.[ch]:
	Move some functions to print parts of the Mercury abstract machine
	state from mercury_trace to mercury_trace_util, so that they are
	available for use in debugging e.g. mercury_trace_declarative.

trace/mercury_trace_internal.c:
trace/mercury_trace_external.c:
trace/mercury_trace_declarative.c:
	Use the new implementation of retries. At the moment, only the
	internal debugger implements the full functionality. The declarative
	debugger issues retry commands only from situations where the missing
	functionality is not (yet) needed. The external debugger should
	continue to work correctly, but Erwan may wish to update it to
	exploit the availability of the fail command.

trace/mercury_trace*.[ch]:
	Fix MR_prefixes, and a signed/unsigned mismatch.

doc/user_guide.texi:
	Document the new "fail" command, but comment it out for now.

tests/debugger/retry.{m,inp,exp,exp2}:
	A new test case for exercising retry.

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

tests/debugger/*.exp:
	Update the expected output, given the extra info now output e.g. for
	exception events and detailed stack traces.
2000-10-13 04:06:52 +00:00
Fergus Henderson
9f3931a8e9 Update to reflect the results of my recent bug fixes.
Estimated hours taken: 0.25

tests/debugger/*.exp:
tests/debugger/*.exp2:
	Update to reflect the results of my recent bug fixes.
1999-11-20 01:03:27 +00:00
Zoltan Somogyi
f0964815a3 Support line numbers in the debugger. You now get contexts (filename:lineno
Estimated hours taken: 40

Support line numbers in the debugger. You now get contexts (filename:lineno
pairs) printed in several circumstances, and you can put breakpoints on
contexts, when they correspond to trace events or to calls. The latter are
implemented as breakpoints on the label layouts of the return sites.

This required extending the debugging RTTI, so that associated with each
module there is now a new data structure listing the source file names that
contribute labels with layout structures to the code of the module. For each
such source file, this table gives a list of all such labels arising from
that file. The table entry for a label gives the line number within the file,
and the pointer to the label layout structure.

compiler/llds.m:
	Add a context field to the call instruction.

compiler/continuation_info.m:
	Instead of the old division of continuation info about labels into
	trace ports and everything else, divide them into trace ports, resume
	points and return sites. Record contexts with trace ports, and record
	contexts and called procedure information with return sites.

compiler/code_info.m:
	Conform to the changes in continuation_info.m.

compiler/options.m:
	Add a new option that allows us to disable the generation of line
	number information for size benchmarking (it has no other use).

compiler/stack_layout.m:
	Generate the new components of the RTTI, unless the option says not to.

compiler/code_gen.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
	Include contexts in the information we gather for the layouts
	associated with the events we generate.

compiler/call_gen.m:
	Include contexts in the call LLDS instructions, for association
	with the return site's label layout structure (which is done after
	code generation is finished).

compiler/handle_options.m:
	Delete the code that tests or sets the deleted options.

compiler/mercury_compile.m:
	Delete the code that tests the deleted options.

compiler/basic_block.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/value_number.m:
compiler/vn_*.m:
	Trivial changes to conform to the changes to llds.m.

compiler/jumpopt.m:
	Do not optimize away jumps to labels with layout structures.
	The jumps we are particularly concerned about now are the jumps
	that return from procedure calls. Previously, it was okay to redirect
	returns from several calls so that all go to the same label, since
	the live variable information associated with the labels could be
	merged. However, we now also associate line numbers with calls, and
	these cannot be usefully merged.

compiler/optimize.m:
	Pass the information required by jumpopt to it.

doc/user_guide.texi:
	Document that you can now break at line numbers.

	Document the new "context" command, and the -d or --detailed option
	of the stack command and the commands that set ancestor levels.

runtime/mercury_stack_layout.h:
	Extend the module layout structure definition with the new tables.

	Remove the conditional facility for including label numbers in label
	layout structures. It hasn't been used in a long time, and neither
	Tyson or me expect to use it to debug either gc or the debugger itself,
	so it has no uses left; the line numbers have superseded it.

runtime/mercury_stack_trace.[ch]:
	Extend the code to print stack traces to also optionally print
	contexts.

	Add some utility predicates currently used by the debugger that could
	also be use for debugging gc or for more detailed stack traces.

trace/mercury_trace_internal.c:
	Implement the "break <context>" command, the "context" command, and
	the -d or --detailed option of the stack command and the commands
	that set ancestor levels.

	Conditionally define a conditionally used variable.

trace/mercury_trace_external.c:
	Minor changes to keep up with the changes to stack traces.

	Delete an unused variable.

trace/mercury_trace_spy.[ch]:
	Check for breakpoints on contexts.

trace/mercury_trace_tables.[ch]:
	Add functions to search the RTTI data structures for labels
	corresponding to a given context.

trace/mercury_trace_vars.[ch]:
	Remember the context of the current environment.

tests/debugger/queen.{inp,exp}:
	Test the new capabilities of the debugger.

tests/debugger/*.{inp,exp}:
	Update the expected output of the debugger to account for contexts.
	In some cases, modify the input script to put contexts where they don't
	overflow lines.
1999-11-15 00:43:59 +00:00
Zoltan Somogyi
3de1010032 Fix an old problem reported by Erwan about six months ago: in some cases,
Estimated hours taken: 5

Fix an old problem reported by Erwan about six months ago: in some cases,
the debugger listed a variable twice at one stop. The reason was that
we can record information about a variable either at a debugging port
or at a call's return site, and some points in the program are both.
The techniques we use to record the variable's details are necessarily
different (the return sites inspection is done after llds optimization),
and associate different insts with the variable. These differences
are irrelevant for RTTI, but they were confusing the code that was
designed to remove any such duplication.

Also fix another old problem: the appearance of "variable names"
such as V_11 in the lists of variables in the debugger. Such
variables should not appear in the debugger's output.

Both of these changes reduce the size of executables built with debugging.

compiler/llds.m:
	Do not use the type inst in the type live_value_type to record
	the instantiation state of a variabe, since the inst contains
	details such as exact functor bindings and uniqueness that RTTI
	is not interested in. RTTI wants to ignore differences in such
	areas, but this is not really possible while using type inst.
	We therefore introduce a new type llds_inst.

compiler/trace.m:
compiler/continuation_info.m:
	Compute llds_insts from insts before creating live_value_type
	structures. This requires access to a module_info to help interpret
	insts.

	In trace.m, do not invent names for live variables if they don't
	already have one.

compiler/code_info.m:
	Supply the module_info argument now needed by the modified predicates
	in continuation_info.

compiler/llds_out.m:
	Update the code for writing out live_value_types.

tests/debugger/queens.exp:
	Update the expected output of this debugger test case, since it
	no longer contains variables such as V_11.
1999-08-16 05:48:44 +00:00
Zoltan Somogyi
c8bb354d02 Fix two errors. One is the same bug (wrong loop variable) in "enable *"
Estimated hours taken: 0.2

trace/mercury_trace_internal.c:
	Fix two errors. One is the same bug (wrong loop variable) in "enable *"
	that Simon fixed in "disable *" a while ago (I checked, but did not
	find any more copies of this bug). The second is that "break info"
	stopped interacting with the user.

tests/debugger/queens.{inp,exp}:
	Test the fixes of these bugs.
1999-08-16 05:35:27 +00:00
Fergus Henderson
ec86c88404 Merge in the changes from the existential_types_2 branch.
Estimated hours taken: 4

Merge in the changes from the existential_types_2 branch.

This change adds support for mode re-ordering of code involving
existential types.  The change required modifying the order of the
compiler passes so that polymorphism comes before mode analysis,
so that mode analysis can check the modes of the `type_info' or
`typeclass_info' variables that polymorphism introduces, so that
it can thus re-order the code accordingly.

This change also includes some more steps towards making existential data
types work.  In particular, you should be able to declare existentially
typed data types, the compiler will generate appropriate unification
and compare/3 routines for them, and deconstruction unifications for them
should work OK.  However, currently there's no way to construct them
except via `pragam c_code', and we don't generate correct RTTI for them,
so you can't use `io__write' etc. on them.

library/private_builtin.m:
compiler/accumulator.m:
compiler/bytecode_gen.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/code_util.m:
compiler/common.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/live_vars.m:
compiler/magic.m:
compiler/make_hlds.m:
compiler/mercury_compile.m:
compiler/mercury_to_c.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_util.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/pd_cost.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/purity.m:
compiler/quantification.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/simplify.m:
compiler/table_gen.m:
compiler/term_traversal.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unused_args.m:
compiler/notes/compiler_design.html:
doc/reference_manual.texi:
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/existential_data_types.m:
tests/hard_coded/typeclasses/existential_data_types.exp:
tests/warnings/simple_code.exp:
tests/hard_coded/Mmakefile:
tests/term/arit_exp.trans_opt_exp:
tests/term/associative.trans_opt_exp:
tests/term/pl5_2_2.trans_opt_exp:
tests/term/vangelder.trans_opt_exp:
tests/term/arit_exp.trans_opt_exp:
tests/term/associative.trans_opt_exp:
tests/term/pl5_2_2.trans_opt_exp:
tests/term/vangelder.trans_opt_exp:
tests/invalid/errors2.err_exp2:
tests/invalid/prog_io_erroneous.err_exp2:
tests/invalid/type_inf_loop.err_exp2:
tests/invalid/types.err_exp2:
tests/invalid/polymorphic_unification.err_exp:
tests/invalid/Mmakefile:
tests/warnings/simple_code.exp:
tests/debugger/queens.exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/existential_reordering.m:
tests/hard_coded/existential_reordering.exp:
	Merge in the changes from the existential_types_2 branch.
1999-06-30 17:13:53 +00:00
Fergus Henderson
1c870062cf Update the expected output for these test cases to reflect the
Estimated hours taken: 0.1

tests/debugger/queens.exp:
tests/debugger/browser_test.exp:
tests/debugger/interpreter.exp:
tests/debugger/interpreter.exp2:
	Update the expected output for these test cases to reflect the
	renumbering of mdb variables starting from 1 rather than from 0.
1999-06-30 15:51:00 +00:00
Zoltan Somogyi
f143c3891f Get the debugger to sort variables better.
Estimated hours taken: 12

Get the debugger to sort variables better.

trace/mercury_trace_vars.[ch]:
	A new module to manage the debugger's information about the variables
	live at the current program point (which can be defined as the
	combination of a specific event and an ancestor level).

	This new module centralizes the management of the (sorted) list of
	current variables. This in turn allows us to use a better sorting
	method, one that orders VarName15 correctly wrt both VarName2 and
	VarName.

	The new module also uses the type, not the name, of a variable
	to decide whether to exclude it from the list of variables
	that may be presented to the user (e.g. if it is a typeinfo
	or a typeclassinfo).

trace/mercury_trace_internal.c:
trace/mercury_trace_external.c:
	Use the new module's facilities. This factors out some "mostly"
	common code.

trace/Mmakefile:
	Add the new module.

runtime/mercury_layout_util.[ch]:
	Remove the code recently moved here from trace/mercury_trace_internal,
	as well as the filtered versions of some functions, since they are
	not needed anymore.

	Move the code for MR_make_var_list to trace/mercury_trace_external,
	since that is the only place where it is used (or is at all likely
	to be used). Since its new home is next to several very similar
	functions, this should also reduce the probability that any required
	maintenance will be overlooked. Also alter its coding style to conform
	to its new neighbours.

	Move the definition of MR_Var_Spec to trace/mercury_trace_vars.h.

tests/debugger/*.exp:
	Update the expected output files. In most cases, this is just because
	the new module outputs different white space, but in some cases, it
	also reflects that the debugger now prints variables in a different
	order.
1999-05-27 01:01:33 +00:00
Zoltan Somogyi
ed1716bf35 Clean up the debugger tests directory by (a) removing the long obsolete
Estimated hours taken: 1

Clean up the debugger tests directory by (a) removing the long obsolete
*_lib files, and (b) separating out the three roles of the queens.m
into mdb_command_test.m and interactive.m as well as queens.m.

tests/debugger/mdb_command_test.m:
	Add a trivial source file for this test. The other files of the test
	case (.inp, .exp) already existed.

tests/debugger/queens.{m,exp,inp}:
	Remove the tests of interactive functionality.

tests/debugger/interactive.{m,exp,inp}:
	A renamed copy of the old queens.m, with the interactive functionality
	intact. Note: since this test case is currently disabled, I cannot
	be sure that the .exp file is quite correct in every detail.

tests/debugger/*_lib.*:
	Removed these obsolete test cases, since for a while now we have
	avoided depending on whether the library was compiled with tracing
	or not by leaving all library code to the end and not printing
	or stopping at any event inside library code.

tests/debugger/Mmakefile:
	Make the necessary updates to accommodate the above changes.
1999-04-16 01:13:04 +00:00
Fergus Henderson
f7df319d0c GNU readline always echos the inputs, so if readline support is
Estimated hours taken: 2

trace/mercury_trace_internal.c:
	GNU readline always echos the inputs, so if readline support is
	enabled, then ignore the MR_echo_commands variable,
	and report an error if the user tries to use `echo off'.
	Also, if we're not using readline, then echo the `echo on' command,
	so that the output will be the same as with readline.

tests/debugger/*.inp:
	Ensure that `echo on' is always the first command.

tests/debugger/*.exp:
tests/debugger/*.exp2:
	Update to reflect the changes to *.inp,
	and to include the echo of the `echo on' command.

	(Also delete the mdb intro banners from *_lib.exp*,
	because mdb is invoked with MERCURY_SUPPRESS_MDB_BANNER=yes.
	The *_lib* files are in fact currently not used, so they should
	probably be just deleted, I think.  But I'll do that as
	a separate change.)
1999-04-08 16:04:27 +00:00
Fergus Henderson
5268018339 Updated to match queens.inp: swap the order of the calls to the
Estimated hours taken: 0.1

tests/debugger/queens.exp:
	Updated to match queens.inp: swap the order of the calls to the
	`mmc_options' command, so that mmc will get invoked *without*
	the `--use-subdirs' option.
	(I had modified queens.inp as described above before committing
	it, and I had forgotten to update queens.exp accordingly.
	The reason I modified queens.inp was to make it work without
	`--use-subdirs'.  Unfortunately getting it to work both with and
	without `--use-subdirs' is non-trivial, so curently it does not
	work with `--use-subdirs'.  I should fix that sometime...)
1999-03-28 01:05:37 +00:00
Fergus Henderson
4aac7dd4c9 Add some test cases to test interactive queries.
Estimated hours taken: 3

Add some test cases to test interactive queries.

tests/debugger/queens.inp:
	Add tests of interactive queries.

tests/debugger/queens.exp:
        Update to reflect the new output for this test case.

tests/debugger/Mmakefile:
	Add dependency of queens.out on queens.ints.
	This is needed in order for us to use interactive queries.

tests/debugger/queens.m:
	Export qperm/2, for use in interactive queries.

browser/interactive_query.m:
	Flush MDB_stdout after printing the prompt, so things work
	properly with I/O redirections.

trace/mercury_trace_internal.c:
	Fix an off-by-one error detected by the above test cases.
1999-03-26 21:12:36 +00:00
Zoltan Somogyi
9aee4beb06 Provide feedback for the "up", "down" and "level" commands in the debugger,
Estimated hours taken: 4

Provide feedback for the "up", "down" and "level" commands in the debugger,
in the form of a line from an enhanced stack dump.

runtime/mercury_stack_layout.h:
	Fix the documentation of the call event number slot.

runtime/mercury_stack_trace.[ch]:
	Generalize the stack dump routines, to make them capable of printing
	the call event number, call sequence number and call depth slots
	of calls to traced procedures.

trace/mercury_trace_internal.c:
	Add a new option, -d or --detailed, to the stack command, which
	prints the call event number, call sequence number and call depth slots
	of every ancestor procedure that is execution traced.

	When changing levels, provide feedback by identifying the call
	to which the level is now set. The feedback is the detailed stack
	trace line for that call.

	When changing levels, check that we have exec trace info for the call,
	not just stack trace info.

	Fix an old bug: tables of long options should be and now are
	terminated by a NULL row.

doc/user_guide.texi:
	Document the new option of the stack command.

	Fix the documentation of the errors in the level change commands.

tests/debugger/queens.{inp,exp}:
	Test the new functionality of the stack command, and update the
	expected output.
1998-11-13 08:40:47 +00:00
Zoltan Somogyi
68ad65bef8 Allow (uniquely-named) variables to be printed by name in the debugger.
Estimated hours taken: 4

Allow (uniquely-named) variables to be printed by name in the debugger.

trace/mercury_trace_internal.c:
	Implement the new functionality. Factor out some common code.
	Make some error messages conform to our conventions.

doc/user_guide.texi:
	Document the new functionality.

tests/queens.{inp,exp}:
	Test the new functionality.
1998-11-12 03:26:38 +00:00
Zoltan Somogyi
63cc6c7d72 Update all the expected outputs to delete the alias echoes
Estimated hours taken: 0.2

tests/debugger/*.exp:
	Update all the expected outputs to delete the alias echoes
	that my previous change turned off.
1998-11-04 04:20:18 +00:00
Zoltan Somogyi
8a0ceb49aa This checkin has several major purposes, set out in the sections below,
Estimated hours taken: 240

This checkin has several major purposes, set out in the sections below,
all connected with the implementation of the new debugger command set.

DOCUMENT NEW DEBUG COMMAND SET

doc/user_guide.texi:
	Add a new section on the debugger. The description of the commands
	is complete, but some of the background sections, and the section
	about how to build debuggable executables, are not yet done.

	Update the documentation of the tracing options.

doc/generate_mdb_doc:
	A new shell script that automatically converts some of the new
	sections of the user guide into the online documentation of the
	debugger.

doc/mdb_categories:
	The fixed initial part of the online documentation.

doc/Mmakefile:
	Add rules for creating mdb_doc, the file that is the online
	documentation of the debugger, and for installing it together
	with mdbrc.

Mmake.common.in:
	Define INSTALL_DOC_DIR for doc/Mmakefile.

scripts/mdbrc.in:
	A debugger command script that reads in the online documentation
	and then defines some standard aliases.

configure.in:
	Define the variable that scripts/mdb.in and scripts/mdbrc.in use
	to find the right files, and get configure to perform the
	substitutions.

configure.in:
scripts/mdb:
scripts/mdb.in:
	Replace mdb with mdb.in. Mdb is now created during configuration
	from mdb.in, filling in the name of the file that contains the default
	debugger initialization commands.

util/info_to_mdb.c:
	A program that does most of the work involved in automatically
	converting user guide sections into online documentation.
	(This couldn't easily be written in sh, because sh's read
	command has no notion of pushback.)

util/Mmakefile:
	Add info_to_mdb to the list of targets.

tools/bootcheck:
	Make sure that the tests in tests/debugger are executed with an
	initialization setup that is equivalent to what users will see
	by default.

REORGANIZE TRACING OPTIONS

compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
compiler/trace.m:
	Reorganize the handling of trace levels around the new options
	--trace-internal, --trace-redo, and --trace-return.

compiler/*.m:
	Use the new ways of getting at trace levels.

tests/hard_coded/typeclasses/Mmakefile:
	s/--trace all/--trace deep/

SUPPORT RETRY

compiler/trace.m:
	After every call to MR_trace(), emit code that checks whether it
	should jump away, and if yes, performs the jump. This is used to
	implement retry. (The debugger cannot execute the jump itself
	because it is in the wrong C stack frame.)

compiler/llds.m:
compiler/continuation_info.m:
compiler/stack_layout.m:
	Modify the data structures that record information about live
	value at program points, to record the identity of each variable.
	This is necessary for the implementation of the restart command,
	since we do not want to confuse two distinct variables just because
	they have the same name. For example, a variable whose name is X
	and number is 5 is now recorded in the name array as "5:X".

	Clean up the data structure a bit, so that we don't have to store
	dummy names for values that are not variables.

compiler/*.m:
	Minor changes to conform to the data structure changes.

runtime/mercury_stack_layout.h:
	Redefine an existing macro to strip away the initial number: prefix
	from the "name" of a variable (keeping its original function on
	changed data), and add a new one to access the raw unstripped data.

runtime/mercury_init.h:
runtime/mercury_wrapper.h:
	Update the prototype of MR_trace_{fake,real}, and the type of the
	global that points to them.

runtime/mercury_layout_util.h:
	Add an extra function, MR_get_register_number, for use by retry.

USE FIXED STACK SLOTS FOR TRACE INFO

compiler/code_gen.m:
compiler/code_info.m:
compiler/live_vars.m:
compiler/trace.m:
	If execution tracing is enabled, reserve the first few stack slots
	to hold the event number of the call event, the call number, the
	call depth, the redo layout structure address (if generating redo
	events) and the from_full flag at the time of call (if we are doing
	shallow tracing). By allocating the first four of these to fixed stack
	slots, the debugger knows where to look for them without having
	to be told. It finds out the location of the fifth, if needed,
	from a new slot in the proc layout structure. (It is not possible
	to allocate all five to fixed stack slots without wasting stack space
	in some cases.)

compiler/trace.m:
	Remove from the call to MR_trace the parameters that are now in fixed
	stack slots, since MR_trace can now look them up itself.

compiler/continuation_info.m:
compiler/stack_layout.m:
	Add an extra field to the proc_layout_info. If the module is shallow
	traced, this field says which stack slot holds the saved value of
	MR_from_full. If it is not shallow traced, this field says that
	there is no such stack slot.

runtime/mercury_stack_layout.h:
	Add macros for accessing the fixed stack slots holding the event
	number of the call event, the call number, the call depth, and,
	at a redo event, the redo layout structure address.

	Support the new field in proc layouts that gives the location of the
	from-full flag (if any).

runtime/mercury_trace_base.[ch]:
trace/mercury_trace.[ch]:
	Remove the call number and call depth arguments from MR_trace
	and its avatars, since this info is now in fixed stack slots
	in every procedure that can call MR_trace. This should reduce
	the size of the executable significantly, since there are lots
	of calls to MR_trace.

runtime/mercury_init.h:
runtime/mercury_wrapper.h:
	Update the prototype of MR_trace_{fake,real}, and the type of the
	global that points to them.

START NUMBERING FRAMEVARS FROM ONE

compiler/code_info.m:
compiler/live_vars.m:
compiler/llds_out.m:
compiler/trace.m:
	Start numbering framevars from 1 internally to the compiler;
	the runtime already starts from 1. This simplifies several tasks.

ADD REDO EVENTS

compiler/trace.m:
compiler/code_gen.m:
	Before the code that executes "succeed()", emit code to push a
	a temp nondet frame whose redoip points to a label in the runtime
	that calls MR_trace for a REDO event and then fails, provided
	--trace-redo is set.

compiler/llds.m:
	Add a new code address constant, do_trace_redo_fail, which stands
	for the address in the trace system to which calls MR_trace for
	the redo event and then fails.

compiler/trace.m:
compiler/llds_out.m:
	Provided we are doing redo tracing, fill in the slot that holds
	the layout information for the REDO event.

compiler/*.m:
	Minor changes to conform to handle the new code address constant.

browser/debugger_interface.m:
	Add redo to trace_port_type.

runtime/mercury_trace_base.[ch]:
	Add a C module containing the code that calls MR_trace for REDO
	events.

ENSURE THAT INPUT ARGUMENTS ARE ALWAYS VISIBLE

compiler/trace.m:
	When generating the set of live variables at internal ports,
	the variables that are in the pre-death set of the goal into which
	we are entering may not be available. However, the variables in the
	pre-death set that are also in the resume vars set will be available,
	so now include info about them in the layout structure for the event.
	Since with tracing the non-clobbered input args are in all resume vars
	sets, this ensures that these input args will be available from all
	internal events.

compiler/code_info.m:
	Export a previously internal predicate (current_resume_point_vars)
	to make this possible.

BUG FIX: WANT RETURN LAYOUTS

compiler/globals.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/mercury_compile.m:
	Add a new pred globals__want_return_layouts, which says whether the
	compiler should generate layout structures for call returns. This pred
	centralizes the several previous copies of the test. One of those
	copies (the one in call_gen) was faulty, leading to a bug: in the
	presence of execution tracing but the absence of accurate gc,
	information about the variables that are live at the call return
	wasn't being gathered properly.

BUG FIX: #include mercury_trace_base.h

compiler/llds_out.m:
	#include mercury_trace_base.h, not mercury_trace.h, since now
	mercury_trace_base.h defines everything directly accessible from
	modules compiled with tracing.

RECAST MERCURY_TRACE_UTIL AS MERCURY_LAYOUT_UTIL

runtime/mercury_trace_util.[ch]:
runtime/mercury_layout_util.[ch]:
	Rename this module from trace_util to layout_util, since it is also
	used by the native garbage collector. Remove "trace" from the names
	of functions.

	Get rid of the global variable MR_saved_regs, and instead thread
	a pointer to this data structure through the relevant functions
	as an extra argument.

	Add a lot more documentation in the header file.

runtime/Mmakefile:
	Reflect the module rename.

runtime/*.c:
	Refer to the new module.

DELETE EASY-TO-MISUSE MACROS

runtime/mercury_stacks.h:
	Delete the based_framevar and based_detstackvar macros, since their
	continued use can lead to off-by-one errors, and the saved_framevar
	and saved_detstackvar macros, since they are no longer used.

runtime/*.c
	Update any references to any macros removed from mercury_stacks.h.

MISC RUNTIME CHANGES

runtime/mercury_trace_base.[ch]:
trace/mercury_trace*.[ch]:
	Make typedef'd names conform to the naming convention.

	Make MR_trace_call_{seqno,depth} consistently Unsigned, rather than
	sometimes Word and sometimes Unsigned.

FIX BUG: MAKE THE DEBUGGER PRINT TO STDOUT, NOT THE CURRENT STREAM

library/io.m:
	Export to C code the predicates that return the identities and types
	of stdin, stdout and stderr, as well as io__print/[34].

library/std_util.m:
	Export to C code a predicate that returns the type_info for the
	type stdutil:type_info. This type_info is required if C code
	wants to invoke make_permanent on any type_info structure,
	as the debugger does.

runtime/mercury_init.h:
	Add extern declarations for the C functions now exported from io.m.

runtime/mercury_wrapper.[ch]:
	Add new global variables to hold the addresses of these C functions.

runtime/mercury_layout_util.c:
	Use indirect calls through these global variables to print Mercury
	values, instead of lower-level code.

util/mkinit.c:
	Assign the addresses of the functions exported from io.m to the
	global variables defined in mercury_wrapper.h.

BUG FIX: STACK TRACE FUNCTIONS DEPEND ON THE LABEL TABLE

runtime/mercury_stack_trace.c:
	On entry to any of the functions exported from this module,
	ensure that the label table is loaded by calling do_init_modules.
	Without a filled-in label table, the stack trace will not be able to
	find any stack layout info.

BUG FIX: REMOVE BROWSER/*.C

configure.in:
	When removing .c files generated by the C compiler, remove those
	in the browser directory as well as the compiler, library and
	profiler directories.

IMPLEMENT NEW DEBUGGER COMMAND SET

runtime/mercury_stack_trace.[ch]:
	Factor out the code that prints the id of a procedure into a function
	of its own, so that it can also be used from the debugger, ensuring
	appearance commonality.

	Add more documentation in the header file.

trace/mercury_trace_internal.c:
	Implement the proposed command set. Command names are now words,
	and several commands now have options allowing the user to override
	the default print level or strictness of the command, or the
	invocation conditions or action of a break point. Allows control
	over command echoing and the scrolling of sequences of event reports.
	Supports aliases, command file sourcing etc. Implements the retry
	command, using the info in the fixed stack slots.

trace/mercury_trace.[ch]:
	Extend the trace controls to support the new functionalities
	required by the new debugger language, which are print levels,
	variable-strictness commands, a more flexible finish command,
	and the retry command.

	Pass the command structure to MR_trace_event_report, since
	the user can now forcibly terminate the scrolling of reports.

trace/mercury_trace_alias.[ch]:
	New module to manage aliases for the debugger.

trace/mercury_trace_help.[ch]:
	New module to interface to browser/help.m.

trace/mercury_trace_spy.[ch]:
	New module to manage break points. The test of whether an event
	matches a break point is now much more efficient than before.
	The new module also allows several breakpoints with different
	actions and different invocation conditions (e.g. all ports,
	entry port, interface ports or specific (possibly internal) port)
	to be defined on the same procedure.

trace/mercury_trace_tables.[ch]:
	New module to manage a table of the debuggable modules, in which
	each such module is linked to the list of the layouts of all the
	procedures defined in that module. This information allows the
	debugger to turn the name of a predicate/function (possibly together
	with its arity and mode number) into the procedure layout structure
	required by the spy point module. Eventually it may also be useful
	in supplying lists of identifiers for command line completion.

	Modules for which no stack layout information is available will
	not be included in the table, since do_init_modules will not
	register any labels for them in the label table.

trace/Mmakefile:
	Mention the new files.

runtime/mercury_array_macros.h:
	A new file holding macros that can be useful in more than one module.

runtime/Mmakefile:
	Mention the new file.

runtime/mercury_conf.h.in:
	Mention a new configuration macro, MR_CANNOT_USE_STRUCTURE_ASSIGNMENT,
	used by runtime/mercury_array_macros.h.

configure.in:
	Find out whether we need to define MR_CANNOT_USE_STRUCTURE_ASSIGNMENT.

ADD TRACE DEPTH HISTOGRAMS

runtime/mercury_conf_param.h:
	Document MR_TRACE_HISTOGRAM.

runtime/mercury_trace_base.[ch]:
	Define the data structures for the histogram, and print the histogram
	when a traced program exits if MR_TRACE_HISTOGRAM is set.

trace/mercury_trace.[ch]:
	If MR_TRACE_HISTOGRAM is defined, record a count of the number of
	events at each depth. This information can help us evaluate space-time
	tradeoffs.

FACTOR OUT SHELL CODE HANDLING GRADE IMPLICATIONS

scripts/final_grade_options.sh-subr:
	A new file to contain any code that implements implications between
	grade flags; currently implements the implication debug -> use trail.

scripts/mgnuc.in:
scripts/ml.in:
	Replace the code that is now in final_grade_options.sh-subr with
	an inclusion of final_grade_options.sh-subr.

configure.in:
	Handle final_grade_options.sh-subr as {init,parse}_grade_options.sh-subr
	are handled.

SIMPLIFY THE MAINTAINANCE OF CONSISTENCY BETWEEN DEBUGGER CODE AND DOCUMENTATION

doc/Mmakefile:
	Add rules for creating mdb_command_list, a C code fragment
	that can included manually in trace/mercury_trace_internal.c
	to supply the list of valid commands, and mdb_command_test.inp,
	which is a list of invalid invocations of debugger commands,
	which tests whether the help message for such invocations
	can be located as expected.

doc/generate_mdb_command_list:
doc/generate_mdb_command_test:
	Awk scripts to create mdb_command_list and mdb_command_test.inp
	respectively from mdb_doc.

tools/bootcheck:
	Copy mdb_command_test.inp from doc to tests/debugger.

tests/debugger/Mmakefile:
	Add a new test that checks whether we get an internal error, unable
	to locate the right help node, for each invalid command invocation in
	mdb_command_test.inp.

UPDATE TEST CASES

tests/debugger/Mmakefile:
	Reenable queens. Conform to the new set of options.

tests/debugger/*.inp:
tests/debugger/*.exp:
	Update the inputs and expected outputs of the debugger test cases
	to use the new command set and output formats.
1998-10-16 06:20:28 +00:00
Zoltan Somogyi
4ab3f397b1 Allow the debugger to print the values of variables in ancestors
Estimated hours taken: 20

Allow the debugger to print the values of variables in ancestors
of the current call. This requires knowledge about which named variables
are live at call return sites. Providing this information properly required
fixing the interaction of execution tracing and accurate garbage collection.

compiler/globals.m:
	Introduce a new trace level, so that there are now four:
	none, interface, interface_ports (corresponding to the existing
	three levels) and the new level interface_ports_returns,
	each of which requires all the information required by lower
	levels.

	Make the trace level abstract, since in the future we may want to
	introduce trace levels for new combinations, e.g. interfaces and
	returns but not internal ports. Introduce the necessary new
	predicates.

compiler/continuation_info.m:
	Redefine internal_label_info to allow us to record separate info about
	the sets of vars needed at (a) internal ports of execution tracing
	and at (b) call return points for accurate gc or (now) uplevel
	printing during execution tracing. Neither is a subset of the other,
	and they need to be treated differently.

compiler/mercury_compile.m:
	Gather information about vars at return labels if the trace level
	requires uplevel printing capability, even if agc is off.

compiler/stack_layout.m:
	Fix the handling of labels which are needed both by agc and by
	execution tracing. If information at a return label is needed only
	by uplevel printing in execution tracing and not by agc, then
	discard all info about lvals which do not hold named variables
	or their typeinfos (in fact we keep all typeinfos at the moment).
	If a label is both the label of a port and a return label, we
	include in the layout structure the union of the information
	recorded for the two roles.

	Sort the var_info vector before using it to generate layout
	structures in an attempt to make llds_common more effective
	and to make lists of variables printed by the debugger look better.

	Record a distinguished value when there is no info about the vars
	live at a label, rather than (incorrectly) recording that there
	are no live variables. Before up-level printing, the lie was harmless;
	now it isn't.

	Remove the label number from return label layouts, since the tracer
	isn't expecting it. It used to be included for debugging purposes
	if the label was for agc, but it is possible for a label to be needed
	both for agc and for execution tracing. If Tyson finds he needs the
	label number, it can be easily turned back on for all label layouts.

compiler/code_info.m:
	Conform to the new definition of internal_label_info.

	Rename an internal pred for clarity.

	Rename some bool parameter to correctly reflect their new meaning.

compiler/*.m:
	Trivial changes, mostly due to making trace_level an abstract type.

runtime/mercury_stack_layout.h:
	Remove the label number from return label layouts, since the tracer
	isn't expecting it.

runtime/mercury_stack_trace.[ch]:
	Add a new function that returns the label layout structure at the
	Nth ancestor return continuation, together with the values of
	sp and curfr at that point. This required changing MR_stack_walk_step
	to step from an entry layout only to the return label layout.

runtime/mercury_stacks.h:
	Add macros that let us access detstackvars and framevars based on
	these synthesized values of sp and curfr.

runtime/mercury_trace_util.[ch]:
	Generalize several functions to allow them to use synthesized
	(as opposed to saved) values of sp and curfr in looking up values.

	Retain functions with the original names and signatures that call
	the new, general versions with the necessary additional parameters.

runtime/mercury_trace_internal.c:
	Add a new command that sets the "ancestor level". For example,
	"l 2" sets it to 2, which means that the command "v" and "p" will
	refer to the grandparent of the current call. The ancestor level
	persists while the debugger is at the current event; after that
	it is reset to 0.

	The implementation involves calling the new function in
	mercury_stack_trace.c and the generalized functions in
	mercury_trace_util.c.

	Also add a deliberately undocumented extra command, X, which
	prints the stack pointers.

NEWS:
	Add a reminder about removing the X command before release.

tests/debugger/*
	Update half the test cases (those which assume a non-debug-grade
	library) to conform to the changes in the debugger interface.
	The others will need to be updated later.
1998-06-18 06:08:37 +00:00
Zoltan Somogyi
67d8308260 Same as previous message. 1998-04-08 11:36:13 +00:00