Commit Graph

31 Commits

Author SHA1 Message Date
Zoltan Somogyi
fbfb5385fa Print more specific errors when creating an mdb breakpoint fails.
trace/mercury_trace_spy.c:
    When giving a command such as

        mdb> break badfilename.m:42

    and the debugger has no information about any file named "badfilename.m",
    print an error message that says just that. If the file exists but the
    line number doesn't, say that. Previously, the error message didn't tell
    the user whether it was the filename or the line number that was in error.

trace/mercury_trace_tables.[ch]:
    Collect the information that mercury_trace_spy.c needs for its new task.

tests/debugger/breakpoints.{inp,exp,exp2}:
    Add a test of both kinds of bad breakpoint specification to this test case.
2014-10-24 02:04:14 +11:00
Julien Fischer
4bf295460a Fix up some places in the trace directory where there were (potential)
Estimated hours taken: 5
Branches: main

Fix up some places in the trace directory where there were (potential)
mismatches between the sizes of types used to represent natural numbers.
Much of the existing code in the trace directory assumed that
sizeof(int) == sizeof(MR_Unsigned), which is not true on our 64-bit
machines.  Zoltan's recent change to MR_trace_is_natural_number() broke
that assumption in a lot of places.  (I committed a workaround for that
yesterday.)

This diff addresses the above problem by changing the types of many of
things that represent natural numbers from int to MR_Unsigned.
This should make the trace code more robust on 64-bit machines and
help avoid a recurrence of problems like the above.

NOTE: this change does not change slot numbers into unsigned values since
they still use negative values as sentinels.  I will address slot numbers
in as part of a separate change.

trace/mercury_trace.h:
	Add typedefs for MR_Unsigned for several commonly used quantities
	within the trace code.  For I/O action numbers we just re-use
	the type MR_IoActionNum from the runtime, rather than defining
	a new typedef here.

trace/mercury_trace_tables.h:
	Change the type of the `match_proc_max' and `match_proc_next' fields
	of the MR_MatchesInfo structure into MR_Unsigned instead of int.

trace/mercury_trace_cmd_parameter.[ch]:
	Change the type of the global variables, MR_scroll_{limit,next}
	and MR_num_context_lines into MR_Unsigned instead of int.

trace/mercury_trace_util.[ch]:
	Restore Zoltan's change that made the type of the second argument of
	MR_trace_is_natural_number() into MR_Unsigned.  The places that
	caused this to break on 64-bit machines have now been fixed.

	Update the documentation of MR_trace_is_natural_number();

	Delete MR_trace_is_unsigned() since that now duplicates
	MR_trace_is_natural_number().

	Add a new function MR_trace_is_nonneg_int() which is similar
	to the above functions except that it stores its result in
	an int.  (This is needed for handling slot numbers which are
	still represented using ints.)

trace/mercury_trace_cmd_developer.c:
	Refactor some code so that we don't need to use -1 as a sentinel
	value.

trace/mercury_trace_cmd_help.c:
	Use MR_trace_is_nonneg_int() instead of MR_trace_is_natural_number()
	to handle slot numbers.

runtime/mercury_trace_base.[ch]:
	Change the type of the first argument of MR_trace_get_action()
	from int to MR_IoActionNum.

trace/mercury_trace_alias.c:
trace/mercury_trace_cmd_backward.c:
trace/mercury_trace_cmd_breakpoint.c:
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_cmd_dd.c:
trace/mercury_trace_cmd_exp.c:
trace/mercury_trace_cmd_forward.c:
trace/mercury_stack_trace.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_spy.[ch]:
trace/mercury_trace_vars.[ch]:
	Use MR_Unsigned instead of int to represent natural numbers.
2007-10-02 03:37:29 +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
544aae2355 Implement synthesized attributes at user events.
Estimated hours taken: 32
Branches: main

Implement synthesized attributes at user events.

doc/user_guide.texi:
	Document synthesized attributes.

runtime/mercury_stack_layout.h:
	Include information about synthesized attributes in layout structures.

	Move the the information about user events that is not specific to a
	given event occurrence to a central table of user event specifications
	in the module layout structure, to reduce the space overhead, and allow
	a future Ducasse style execution monitor to look up information about
	each event without having to search all label layout structures (e.g.
	when compiling a set of user commands about what to do at each event
	into a state machine).

	Update the current layout structure version number.

	Introduce a named type to represent HLDS variable numbers in layout
	structures.

runtime/mercury_types.h:
	Add typedefs for the new types in mercury_stack_layout.h.

compiler/prog_data.m:
compiler/prog_event.m:
	Record the call that synthesizes synthesized attributes in terms of
	attribute numbers (needed by the layout structures) as well as in terms
	of attribute names (the user-friendly notation). Record some other
	information now needed by the layout structures, e.g. the evaluation
	order of synthesized attributes. (Previously, we computed this order
	-in reverse- but then threw it away.)

	Do not separate out non-synthesized attributes, now that we can handle
	even synthesized ones. Return *all* attributes to call_gen.m.

	Pass the filename of the event set specification file to the event
	spec parser, for use in error messages.

	Generate better error messages for semantic errors in event set
	specifications.

compiler/continuation_info.m:
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
	Generate the new layout structures, the main changes being the
	inclusion of synthesized attributes, and generating information about
	event attribute names, types and maybe synthesis calls for all possible
	events at once (for the module layout) instead of separately at each
	user event occurrence.

	In stack_layout.m, rename a couple of predicates to avoid ambiguities.

	In layout_out.m, eliminate some repetitions of terms.

compiler/call_gen.m:
	When processing event calls, match the supplied attributes against the
	list of all attributes, and include information about the synthesized
	attributes in the generated layout structures.

compiler/equiv_type.m:
compiler/module_qual.m:
	Conform to the change in prog_data.m.

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

compiler/hlds_out.m:
	Generate valid Mercury for event calls.

trace/mercury_event_spec.[ch]:
	Record the name of the file being parsed, for use in syntax error
	messages when the parser is invoked by the compiler.

	Add a field for recording the line numbers of attributes, for use in
	better error messages.

trace/mercury_event_parser.y:
trace/mercury_event_scanner.l:
	Record the line numbers of attributes.

	Modify the grammar for event set specifications to allow C-style
	comments.

trace/mercury_trace_internal.c
	Pass a dummy filename to mercury_event_spec. (The event set
	specifications recorded in layout structures should be free of errors,
	since the compiler generates them and it checked the original version
	for errors.)

trace/mercury_trace_tables.[ch]:
	Conform to the new design of layout structures, and record the extra
	information now available.

trace/mercury_trace_vars.[ch]:
	Record the values of attributes in two passes: first the
	non-synthesized attributes, then the synthesized attributes
	in the evaluation order recorded in the user event specification.

tests/debugger/synth_attr.{m,inp,exp}:
tests/debugger/synth_attr_spec:
	New test case to test the debugger's handling of synthesized
	attributes.

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

tests/invalid/syntax_error_event.{m,err_exp}:
tests/invalid/syntax_error_event_spec:
	New test case to test the handling of syntax errors in event set
	specifications.

tests/invalid/synth_attr_error.{m,err_exp}:
tests/invalid/synth_attr_error_spec:
	New test case to test the handling of semantic errors in event set
	specifications.

tests/invalid/Mmakefile:
	Enable the new test cases.
2006-12-14 04:36:04 +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
455e1eea75 The runtime had two different conventions for naming types.
Estimated hours taken: 2
Branches: main

The runtime had two different conventions for naming types. One convention,
used mostly in the debugger-related modules, added underscores between
capitalized words; example: MR_Label_Layout. The other convention, used
in most modules, used capitalized words without underscores (e.g. MR_TypeInfo).

This diff standardizes on the second convention. It has no algorithmic changes,
only renames of types.

runtime/*.[ch]:
trace/*.[ch]:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
	Effect the change described above. The only substantive change is that
	runtime/mercury_stack_layout.h used to define *two* types for trace
	levels: MR_TraceLevel and MR_Trace_Level, and this diff standardizes
	on just one (they had equivalent definitions).

runtime/mercury_bootstrap.h:
	Add a #define from the old name to the new for all the changed type
	names that the installed compiler can put into .c files. We can delete
	these #defines some time after this diff has bootstrapped.

slice/.mgnuc_opts:
	Restore the --no-mercury-stdlib-dir option, without which the slice
	directory won't compile after this change (because it looks for type
	names in the installed runtime header files, which define the old
	versions of type names).
2006-11-29 05:18:42 +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
Zoltan Somogyi
e65ee0f43f Convert to four-space indentation all modules that have not previously
Estimated hours taken: 1
Branches: main

trace/*.[ch]:
	Convert to four-space indentation all modules that have not previously
	been so converted.
2006-11-10 03:24:18 +00:00
Zoltan Somogyi
648f29c06f Extend the mdb command "ambiguity" to report information about not just
Estimated hours taken: 3
Branches: main

Extend the mdb command "ambiguity" to report information about not just
ambiguous procedure names and type constructor names but also ambiguous
function symbols.

trace/mercury_trace_tables.[ch]:
	Implement the new capability.

	Declare some static functions at the top of the file before
	their definitions.

trace/mercury_trace_cmd_developer.c:
	Add new options -p, -t and -f that allow the user to select the
	printing of ambiguity information about procedure names, type
	names and/or function symbols.

doc/user_guide.texi:
	Document the new functionality and options.

trace/mercury_trace_spy.c:
	Minor style fix.

tests/debugger/ambiguity.{m,exp}:
	Extend this test case to test the new functionality, and update the
	expected output.
2006-08-20 05:41:45 +00:00
Zoltan Somogyi
0ecbc0efb0 Fix some bugs in the mdb "ambiguity" command, and add an enhancement to it.
Estimated hours taken: 2
Branches: main

Fix some bugs in the mdb "ambiguity" command, and add an enhancement to it.

doc/user_guide.texi:
	Document the enhancement: users can now restrict the set of modules
	in which the debugger looks for ambiguity.

tests/debugger/ambiguity.{m,inp,exp}:
	A new test case to check the new functionality and the bug fix.

tests/debugger/Mmakefile:
	Enable the new test.

trace/mercury_trace_tables.[ch]:
	Fix two bugs in the implementation of the function that implements
	the ambiguity command. One was that we neglected to differentiate
	between predicates and functions of the same name and arity. Another
	was that for functions, we used the wrong arity: the one after the
	addition of the result as an argument, not the one before.

	Add the ability to restrict the search to a list of named modules.

trace/mercury_trace_internal.c:
	Update the parsing of the command line for ambiguity commands to allow
	users to specify lists of module names.

	Fix an old bug, and make sure it never happens again. We used to
	pass the category and name of the current command every time we
	reported a syntax error, or called an option parsing routine (since it
	may have to report a syntax error). Since much of this code is best
	done via cut-and-paste, we often passed the wrong strings. For example,
	before this fix, a syntax error in an ambiguity command lead to a
	suggestion to do "help class_decl"!

	The fix is simply to record the category and name of the current
	command in a pair of variables, and refer to these variables when
	reporting syntax errors.

	Note that there are still mismaches in the names of categories
	between mercury_trace_internal.c and user_guide.texi. These should
	be fixed, but for now things are fine, since our current error messages
	don't include the category name.
2006-03-01 22:58:51 +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
Zoltan Somogyi
f7c8e5899d Add a new tabling method, one which specifies how each argument should
Estimated hours taken: 20
Branches: main

Add a new tabling method, one which specifies how each argument should
be treated, like this:

    :- pragma memo(p(in, in, in, out), [value, addr, promise_implied, output]).

doc/reference_manual.texi:
	Document the new tabling method.

compiler/prog_data.m:
	Add a new tabling method, one which specifies how each argument should
	be treated.

compiler/hlds_pred.m:
	Provide for the description of untabled input arguments of tabled
	procedures.

compiler/prog_io_pragma.m:
	Parse the new tabling method.

	Fix a bunch of formatting problems.

compiler/add_pragma.m:
	When adding a tabling pragma to the HLDS, check that if the pragma
	individually specifies the tabling methods of a procedure's arguments,
	then those tabling methods agree with the modes of those arguments.

	Fix an old bug: check whether a tabled predicate's arguments are
	fully input or fully output, and print an error message if not.
	We used to check this only in table_gen.m, but there we could only
	abort the compiler if the check failed.

	Factor out some common code and thereby fix an old bug: check for
	conflicting tabling pragmas not just when adding the pragma to all
	procedures of a predicate, but also when adding it to only a
	specified procedure.

compiler/table_gen.m:
	Implement the new tabling method.

compiler/prog_out.m:
compiler/layout_out.m:
	Conform to the changes above.

runtime/mercury_stack_layout.h:
	Provide for the description of untabled input arguments of tabled
	procedures.

trace/mercury_trace.c:
	Handle the new tabling method.

trace/mercury_trace_internal.c:
	Handle the new tabling method. Delete the defaults from some switches
	on enums to allow gcc to recognize missing cases.

	Handle the untabled input arguments of tabled procedures: skip over
	them when printing procedures' call tables.

	Enable better completion for mdb's "table" command.

trace/mercury_trace_tables.[ch]:
	Rename the breakpoint completer the proc_spec completer, since it does
	completions on procedure specifications.

tests/debugger/print_table.{m,inp,exp}:
	Modify this test case to test the ability to print the tables of
	predicates with some untabled arguments.

tests/tabling/specified.{m,exp}:
	New test case to check the functioning of the new tabling method
	by testing whether it is in fact faster to table the address of
	an argument instead of its value, or to not table it at all.
	Since the gains here are not quite as dramatic as tabled vs untabled,
	use a slightly looser criterion for comparing speeds than we use
	in the various versions of the fib test case.

tests/tabling/Mmakefile:
tests/tabling/Mercury.options:
	Enable the new test case, and set up the option it needs.

tests/invalid/specified.{m,err_exp}:
	New test case, a slight variant of tests/tabling/specified.m,
	to check the compiler's ability to detect errors in the new form
	of tabling pragma.

tests/invalid/Mmakefile:
	Enable the new test case.
2005-08-14 03:20:59 +00:00
Ian MacLarty
d032b79be0 Only show procedures *declared* in a the module given to the `procedures' mdb
Estimated hours taken: 1
Branches: main and 0.12

Only show procedures *declared* in a the module given to the `procedures' mdb
command.

trace/mercury_trace_tables.c:
	Check that each procedure is declared in the named module before
	printing it.

trace/mercury_trace_tables.h:
	Add a function to get the name of module in which the procedure
	is declared.
2005-07-28 07:03:35 +00:00
Zoltan Somogyi
40bf6f1235 Extend the functionality of the existing function for dumping lists
Estimated hours taken: 1
Branches: main

trace/mercury_trace_tables.[ch]:
	Extend the functionality of the existing function for dumping lists
	of procedures to allow the caller to specify that only procedures
	from a given module should be dumped.

trace/mercury_trace_internal.c:
	Change the existing "all_procedures" command to take an option
	specifying the module to be dumped.

doc/user_guide.texi:
	Document the changes to the all_procedures command.
2005-02-14 08:04:03 +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
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
642c902c90 Reduce the sizes of .c and .o files in debug grades by 8%.
Estimated hours taken: 4
Branches: main

Reduce the sizes of .c and .o files in debug grades by 8%.

Add to mdb the capability of putting breakpoints on unify, compare and index
predicates.

compiler/code_gen.m:
	Since compiler-generated unify, index and compare pred can be presumed
	to be correct, compile them with shallow tracing instead of deep
	tracing even if the user asks for deep tracing of the rest of the
	module. This saves disk space, compile time and run time.

	Move the code for setting the trace level to generate_proc_code,
	where it is executed whether we generate code by predicates or by
	phases.

compiler/trace_params.m:
	Provide a function for use by code_gen.m.

	Consider unify and compare predicates to behave as if their address
	were taken, since they may be called from builtin.unify or
	builtin.compare.

compiler/jumpopt.m:
	Do not replace jumps with the block being jumped to if the block
	contains an instruction that represents a call to the debugger.
	In such cases, the jump is a minor cost in runtime compared to the
	call, and the locality benefit from not increasing the code size is
	quite likely to exceed that cost.

compiler/llds.m:
	Add field names to pragma_c instructions to make the change to jumpopt
	easier.

tests/debugger/uci.{inp,exp}:
	Update this test case. An update is required since we now generate
	fewer events from unify and compare preds due to their now being
	shallow traced.

	To make this the update easier, use the new capability of putting
	breakpoints on unify and compare predicates.

trace/mercury_trace_tables.[ch]:
	Expand procedure specifications to allow the specification of unify,
	compare and index predicates, and expand the function that checks for
	matches between a procedure layout and a procedure specification
	accordingly.

	Fix two instances of a bug: if a procedure specification has no name,
	represent it as NULL, not as a non-NULL pointer to a null character,
	since the match function expects only the former.

doc/user_guide.texi:
	Document the new definition of procedure specifications.

NEWS:
	Mention the new definition of procedure specifications, and expand
	on some previous additions to the debugger.

runtime/mercury_stack_trace.c:
	Allow mdb breakpoint specifications on uci predicates to be saved.

	Factor out some common data structure accesses.

runtime/mercury_proc_id.h:
	Change the name of a macro from MR_PROC_ID_COMPILER_GENERATED to
	MR_PROC_ID_IS_UCI, for consistency with other names dealing with
	unify, compare and index predicates.

runtime/*.[ch]:
trace/*.[ch]:
	Conform to the change in mercury_proc_id.h.
2004-05-23 22:16:57 +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
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
Simon Taylor
32051f5467 Add support for command line completion to mdb.
Estimated hours taken: 40
Branches: main

Add support for command line completion to mdb.

NEWS:
	Document the change.

trace/mercury_trace_completion.{c,h}:
	Define the framework for completion.
	Examine command lines to determine which completers to use.

trace/mercury_trace_alias.{c,h}:
trace/mercury_trace_help.{c,h}:
trace/mercury_trace_internal.{c,h}:
trace/mercury_trace_tables.{c,h}:
trace/mercury_trace_vars.{c,h}:
	Define context-specific completers.

trace/mercury_trace_help.c:
	Record all help topics in an array for use by the completer.

trace/mercury_trace_internal.c:
	Add completion information to the list of commands.
	Add a function MR_trace_command_completion_info to access
	that information.

runtime/mercury_wrapper.{c,h}
	Add a runtime option `--force-readline', which tells mdb to
	use readline even if MR_mdb_in is not a tty. This is needed
	for tests/debugger/completion. `--force-readline' is not
	documented because I'm not sure that it will work properly
	in all situations (it's fine for the test).

	Fix capitalisation in references to the Mercury User's Guide
	in error messages.

trace/mercury_trace_readline.c:
	Tell Readline to use our completer.

	Handle `--force-readline'. Disable some Readline terminal
	initialisation code which reports spurious warnings if the
	input stream is not a tty.

trace/Mmakefile:
	Add mercury_trace_completion.{c,h}.

runtime/mercury_array_macros.h:
	Define a macro MR_find_first_match, which is like MR_bsearch
	except that it finds the first match, not an arbitrary match.

runtime/mercury_memory.c:
	Handle NULL pointers in MR_copy_string();

runtime/mercury_memory.h:
	Add a macro MR_free_func which returns the address of free().
	Used where it is necessary to pass the address of MR_free().

tests/debugger/Mmakefile:
tests/debugger/completion.m:
tests/debugger/completion.exp:
tests/debugger/completion.inp:
tests/debugger/completion.inputrc:
tests/debugger/completion.sub1.m:
tests/debugger/completion.sub2.m:
tests/debugger/completion.sub2.sub3.m:
	Test case.
2002-03-06 14:35:06 +00:00
Simon Taylor
b7c4a317e9 Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4
Branches: main

Add MR_ prefixes to the remaining non-prefixed symbols.

This change will require all workspaces to be updated
The compiler will start generating references to MR_TRUE,
MR_bool, etc., which are not defined in the old runtime
header files.

runtime/mercury_std.h:
	Add MR_ prefixes to bool, TRUE, FALSE, max, min,
	streq, strdiff, strtest, strntest, strneq, strndiff,
	strntest, NO_RETURN.

	Delete a commented out definition of `reg'.

runtime/mercury_tags.h:
	Add an MR_ prefix to TAGBITS.

configure.in:
runtime/mercury_goto.h:
runtime/machdeps/i386_regs.h/mercury_goto.h:
	Add an MR_ prefix to PIC.

runtime/mercury_conf_param.h:
	Allow non-prefixed PIC and HIGHTAGS to be defined on
	the command line.

runtime/mercury_bootstrap.h:
	Add backwards compatibility definitions.

RESERVED_MACRO_NAMES:
	Remove the renamed macros.

compiler/export.m:
compiler/ml_code_gen.m:
	Use MR_bool rather than MR_Bool (MR_Bool is
	meant to be for references to the Mercury type
	bool__bool).

runtime/mercury_types.h:
	Add a comment the MR_Bool is for references to
	bool__bool.

*/*.c:
*/*.h:
*/*.m:
	Add MR_ prefixes.
2002-02-18 07:01:33 +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
Zoltan Somogyi
2498d9d3fd Instead of generating the layout structures of labels, procs and modules
Estimated hours taken: 36

Instead of generating the layout structures of labels, procs and modules
as rvals, generate them almost entirely as C structures. This will make
future modifications much easier, since mismatches between what the runtime
expects and what the compiler generates will now be pointed out by the C
compiler. (It also reduces the size of the C source files generated with
debugging enabled by about 5%.) Layout structures contain a few components
that are not well-typed in C; we continue to generate these as rvals.

Closure layout structures used to have a well-typed part and a non-well-typed
part. We now generate the well-typed part as a separate structure, pointed to
from the other. We also extend the well-typed part, so that instead of
just giving the name the called procedure, it also identifies the source
location where the closure was constructed. This could be useful for
the debugger and for deep profiling.

This diff also includes a change to get the compiler to bootstrap with lcc
in grade none.gc.debug.tr: initializing the string tables in module layouts
not as a string but as an array of characters.

runtime/mercury_stack_layout.h:
	Reorganize the definitions of layout structures. Rename
	Stack_Layout_Entry structures as Proc_Layout structures,
	and Stack_Layout_Label structures as Label_Layout structures.
	(The debugger paper refers to the structures by the new names.)
	Fold the Stack_Layout_Vars structure into the structure that contains
	it, the Label_Layout structure. Add a Closure_Id structure that
	contains a Proc_Id structure as well as extra information identifying
	the source location where the closure was created.

	Create "short" versions of the Proc_Layout structures, which contain
	only the first one or two of the three groups of fields. Previously,
	the Mercury compiler would define new C types when it generated such
	short structures. Since we are not defining new C types anymore, there
	must be a C type for every kind of structure the Mercury compiler can
	generate. We now also have separate variants for the layouts of
	user-defined and compiler-generated procedures, since the format
	of their procedure id information is different. While the runtime
	system refers to their procedure id information through a union,
	the C types of the structures generated by the Mercury compiler
	do not use a union, since a union cannot be initialized through
	its second member.

	Make the constant fields of structures const, since we now generate
	values of those structure types, and initialize them with constant
	data.

	Move the documentation of layout structures here from stack_layout.m.

runtime/mercury_ho_call.h:
	Instead of bodily including an MR_Proc_Id structure in closures,
	include a pointer to the more detailed MR_Closure_Id structure.

runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
runtime/mercury_init.h:
runtime/mercury_label.[ch]:
runtime/mercury_layout_util.[ch]:
	Minor updates to conform to changes in mercury_stack_layout.h.

runtime/mercury_goto.h:
	Use separate naming schemes for label layout structures and proc layout
	structures.

library/exception.m:
	Minor updates to conform to changes in mercury_stack_layout.h.

compiler/layout.m:
	A new module that defines data structures for label, proc and module
	layout structures and for closure id structures.

compiler/layout_out.m:
	A new module that converts the Mercury data structures of layout.m into
	declarations and definitions of C data structures.

compiler/stack_layout.m:
	Generate the new layout structures instead of rvals.

	Move the documentation of layout structures from here to
	runtime/mercury_stack_layout.h, since this module is no longer
	aware of some of their details.

compiler/llds.m:
	Make layout structures a separate kind of compiler-generated data.

compiler/llds_out.m:
	Remove the code for the output of layout structures; call layout_out.m
	instead.

compiler/llds_out.m:
compiler/rtti_out.m:
	Turn some predicates into functions.

compiler/code_gen.m:
compiler/code_info.m:
compiler/llds.m:
compiler/mercury_compile.m:
compiler/unify_gen.m:
	Instead of handling closure layouts like other static data, handle
	them separately. Add a counter to the code_info structure in order
	to allow closure id structures to be identified uniquely by a pair
	consisting of the id of the procedure that generates them and a closure
	sequence number within that procedure.

compiler/llds_common.m:
	Look for common rvals among the rvals in layout structures.

compiler/opt_debug.m:
	Generate developer-friendly names for layout structure references.

browser/dl.m:
	Update the code for constructing closure layouts.
2001-01-18 01:19:17 +00:00
Zoltan Somogyi
004fb7471c Add a new debugger command for developers: label_stats, which prints a
Estimated hours taken: 1.5

Add a new debugger command for developers: label_stats, which prints a
histogram of the ports associated with labels. Its output can be useful
in making predictions about the impact of proposed changes in the structures
of label layouts.

trace/mercury_trace_tables.[ch]:
	Add the code to print the histogram.

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

doc/user_guide.texi:
	Document the label_stats command, as well as the all_regs and table_io
	commands, which were previously not listed.

doc/mdb_categories:
	Update the list of developer commands.
2001-01-09 04:10:04 +00:00
Zoltan Somogyi
3f84f112ec Handle ambiguous procedure specifications in the debugger's "break" command
Estimated hours taken: 3

Handle ambiguous procedure specifications in the debugger's "break" command
more usefully.

trace/mercury_trace_tables.[ch]:
	Add a function for returning all the procedures that match a
	specification.

trace/mercury_trace_internal.c:
	Use this function to present the user all the matches for the procedure
	specification if their specification matches more than one procedure,
	and let them choose whether they want to put a breakpoint on them all,
	and if not, which one to put the breakpoint on.

doc/user_guide.texi:
	Document the new functionality.

tests/debugger/breakpoints.{m,in,exp}:
	Introduce a function named "data" to go with the predicate, and check
	that the "break" command handles the ambiguity properly.
2000-08-25 09:53:37 +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
e3232306cb Add a module layout structure containing a string table and a table of
Estimated hours taken: 14

Add a module layout structure containing a string table and a table of
pointers to the proc layouts of the module's procedures. This speeds up
debugger initialization, and reduces the executable size of the compiler
by almost 1.2 Mb (about 3.7%) when compiled with debugging.

Instead of representing variables names as strings (32 or 64 bit pointers)
in the debugger's static data structures, with the string's prefix representing
the variable's number (e.g. "5:X"), represent them as a 16-bit variable number
and a 16 bit offset into the module-wide string table. This gains simplicity
of processing (no more search for the ":") and reduces the amount of storage
required, a bit on 32-bit platforms (we don't have to store "5:ModuleInfo"
and "10:ModuleInfo" strings separately, and there are no string prefixes to
store) and more on 64-bit platforms.

The 16-bit limits are generous. A procedure with more than 64K variables will
take forever to compile (that is why we impose a 4K limit on the number
of variables in inlining), and even the string tables of typecheck.m and
make_hlds require less than four kilobytes each. Exceeding the limits
would require code no human would write. Automatically generated code may
be a problem, but the help the debugger can give on such code is limited
already. In any case, we detect overflows and handle them sensibly.

This change does not enhance the debugger to take advantage of the easier
availability of variable numbers, except to improve the implementation
of retry; that will come later.

The inclusion of the procedure table in the module layout structure
reduces the cost of registering all procedures in all modules,
a task usually performed at the time of the setting of the first breakpoint.
This used to require processing all the internal labels in the label table,
and thus used to take a few seconds for large executables. The sweep of
all internal labels is no longer required, so registering is now much faster.

runtime/mercury_stack_layout.h:
	Add the definition of MR_Module_Layout.

	Modify label layouts to represent names as offsets in the string table,
	not as raw character pointers. This required modifing proc layouts
	to include a pointer to the module's layout, so you can find the
	string table.

	Update the macros that look up variable names.

runtime/mercury_layout_util.h:
	Use the updated macros for looking up variable names.

runtime/mercury_wrapper.[ch]:
	Add a new indirect pointer, MR_register_module_layout, which points
	to a function that registers a module layout, or is NULL if debugging
	is not enabled.

runtime/mercury_init.h:
	Declare the function whose address may be assigned to
	MR_register_module_layout in a <main>_init.c file.

util/mkinit.c:
	Initialize MR_register_module_layout with either the address of
	MR_register_module_layout_real or NULL, depending on whether
	debugging is enabled or not.

compiler/continuation_info.m:
	Don't give names (V_n) to nameless variables, because we don't want
	them to be included in the variables debugging knows about.

compiler/llds.m:
	Add a new function symbol to the type data_addr, which stands for
	the module layout structure of the named (now always the current)
	module.

	Add a new function symbol to the type rval_const. The new function
	symbols, multi_string_const, contains an array of characters of an
	explicitly given length, which consists of several strings, each
	terminated by a null character.

compiler/llds_out.m:
	Accommodate the changes to llds.m, and expand the module initialization
	code to register the module layout structure, if the pointer to the
	registration function is not NULL.

compiler/stack_layout.m:
	Generate the new data structures for representing variable names,
	as well as the module layout.

compiler/mercury_compile.m:
	Rename some variables to reflect the fact that stack_layout.m can
	now include a module layout structure in the list of static layout
	structures it returns.

compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/opt_debug.m:
	Minor changes to accommodate multi_string_consts.

trace/mercury_trace_tables.[ch]:
	Replace the old data structures for recording information about
	each debuggable module with the module layout structure, and
	register module layout structures directly, instead of trying
	to discover them through the internal label table.

trace/mercury_trace.[ch]:
	Now that it is more easily accessible, use variable numbers
	instead of variable names to find the current locations of
	the input arguments when implementing retry. Unlike our previous
	method, this works even if the user names some variables HeadVar__1,
	etc.

	Remove an unnecessary export of an internal function.

trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
runtime/mercury_layout_util.c:
	Use the updated macros for looking up variable names.
1999-05-28 05:29:51 +00:00
Erwan Jahier
5a356066ae Moves the definition of MR_dump_stack_record_print() and MR_print_proc_id()
Estimated hours taken: 3

Moves the definition of MR_dump_stack_record_print() and MR_print_proc_id()
from trace/ to runtime/ to be able to call MR_dump_stack_record_print() from
MR_dump_stack(). Indeed we can not pass down *MR_dump_stack_record_print() as a
parameter of MR_dump_stack() since MR_dump_stack() is called from the library
and we have to repect the invariant "trace -> library -> runtime".

runtime/mercury_stack_trace.c:
	Add the missing argument of MR_dump_stack_from_layout() in the body of
	MR_dump_stack().

runtime/mercury_stack_trace.[ch]:
trace/mercury_trace_internal.c:
trace/mercury_trace_tables.[ch]:
	Move the definition of MR_dump_stack_record_print() from
	mercury_trace_internal.c to mercury_stack_trace.c and
	MR_print_proc_id() from mercury_trace_tables.c to mercury_stack_trace.c

runtime/mercury_stack_trace.[ch]:
trace/mercury_trace.[ch]:
	Move the definition of MR_detism_names[] from mercury_trace.c to
	mercury_stack_trace.c.
1999-02-23 08:06:55 +00:00
Erwan Jahier
9760975d5e This change implement stack dump commands for the external debugger.
Estimated hours taken: 7

This change implement stack dump commands for the external debugger.

The MR_dump_stack_record_print() defined in runtime/mercury_stack_trace.c is
the function that prints the contents of the stack. We move the definition of
this function to mercury_trace_internal.c and we pass down that function as a
parameter of MR_dump_stack_from_layout(). The rational for this change is that
we can then define a new MR_dump_stack_record_print_to_socket() in
mercury_trace_external.c that prints the data to the socket as a Prolog term
and pass down the address of that new function to MR_dump_stack_from_layout().


browser/debugger_interface.m:
	Add three new kinds of requests: stack, nondet_stack and stack_regs.

trace/mercury_trace_external.c:
	Define new MR_dump_stack_record_print_to_socket() and
	MR_print_proc_id_to_socket() that sends data to the socket as Prolog
	terms.

	Add support for stack, nondet stack and stack_regs requests.

runtime/mercury_stack_trace.[ch]
trace/mercury_trace.[ch]:
trace/mercury_trace_internal.[ch]:
	Move the definition of MR_dump_stack_record_print(),
	from mercury_stack_trace.c to mercury_trace_internal.c.

	Add MR_dump_stack_record_print() as an argument of all the
	functions that need it in mercury_stack_trace.c.

	Move the definition of detism_names[] from mercury_stack_trace.c
	to mercury_trace.c. This function is needed by both versions of
	MR_dump_stack_record_print(). Rename detism_names[] by
	MR_detism_names[].

runtime/mercury_stack_trace.[ch]
trace/mercury_trace_tables.[ch]:
	Move the definition of MR_print_proc_id() and
	MR_print_proc_id_for_debugger() from mercury_stack_trace.c to
	mercury_trace_tables.c since MR_print_proc_id() is called in that
	module.

	Include mercury_trace.h since we now make use of detism_names[] there.
1999-02-18 23:33:02 +00:00
Fergus Henderson
9d0fd6601a Add support to mdb for doing the debugger I/O in a different
Estimated hours taken: 4

Add support to mdb for doing the debugger I/O in a different
window to the I/O of the program being debugged.

(TODO: I/O from the browser still goes to the standard I/O streams
rather than the debugger I/O streams.  I will commit that soon
as a separate change.)

runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
	Add new runtime options for specifying filenames
	for the mdb I/O streams.

doc/user_guide.texi:
	Document the new options.

trace/mercury_trace_internal.c:
	Add three new variables holding the mdb I/O streams.
	Initialise them based on the option settings.
	Change the code so that all I/O goes through these streams.

trace/mercury_trace_tables.c:
trace/mercury_trace_tables.h:
	Pass a `void *' parameter through MR_process_matching_procedures()
	to the function it calls.  This is needed by mercury_trace_internal.c
	to pass `MR_mdb_in' down to MR_print_proc_id_for_debugger().

runtime/mercury_stack_trace.c:
runtime/mercury_stack_trace.h:
	Add a `FILE *' parameter to MR_print_proc_id_for_debugger().

tests/debugger/Mmakefile:
	When creating the `.out' files, redirect stderr as well as stdout,
	since debugger error messages now go to stderr rather than stdout.
1998-12-17 13:37:19 +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