mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-25 22:34:26 +00:00
784dc26cabb5b24beb94de12a0ff6faae3536d47
26 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
55d0d482c6 |
Provide a more uniform interface to the test directories.
Estimated hours taken: 9 Provide a more uniform interface to the test directories. Before this change, the tests directory as well as direct descendents had `runtests' scripts to execute the tests. These would run `mmake', which in turn would recursively run `mmake' in any subdirectories. The subdirectories did not have their own `runtests' scripts. This change adds a `runtests' script to those subdirectories that did not have them before. The scripts have the same meaning as they did previously---run all tests in the current directory and below, and return a status of 0 only if all tests pass. The rationale for this change is so that each directory in the tests is treated the same, regardless of whether it is a top-level directory or not. This means, for example, that any test directory can be used as an argument to the `--test-dir' option to tools/bootcheck. This change also links tests/general/accumulator into the automated testing suite. tests/README: Update comments. tests/Mmake.common: Introduce new target dependencies. Targets of the form `foo' depend on the targets `foo_local' and `foo_subdirs'. tests/subdir_runtests: New script to recursively call runtests scripts in subdirectories. Most of the code for this script originally came from tests/runtests. tests/shutdown: tests/startup: Use `realclean_local' as a target instead of `realclean', since the subdirectories will be handled by other runtests scripts. tests/runtests: tests/debugger/runtests: tests/general/runtests: tests/hard_coded/runtests: Use the new script to run tests in the subdirectories, rather than doing a recursive mmake. Make sure that non-zero return values are propagated upwards where appropriate. tests/debugger/declarative/runtests: tests/hard_coded/typeclasses/runtests: tests/hard_coded/sub-modules/runtests: New scripts to handle running tests in the subdirectories. tests/debugger/Mmakefile: tests/general/Mmakefile: tests/hard_coded/Mmakefile: Add `*_subdirs' targets that do a recursive Mmake. Change the existing targets to `*_local' ones. tests/warnings/Mmakefile: Manually add the extra dependencies, since this Mmakefile does not include tests/Mmake.common. |
||
|
|
5db4b3befd |
Make declarative debugging enabled by default, and add test cases.
Estimated hours taken: 4 Make declarative debugging enabled by default, and add test cases. The declarative debugger, while not complete, is fairly stable so users will be able to experiment with it after this change without having to re-configure the whole system. However, the main motivation for this change is so that developers who make changes to the system will have access to these test cases. configure.in: Turn the decl-debug feature on by default. tests/debugger/declarative: New directory containing tests for the declarative debugger. tests/debugger/declarative/*.m: tests/debugger/declarative/*.inp: tests/debugger/declarative/*.exp: Declarative debugger test cases. tests/debugger/declarative/Mmakefile: Mmakefile to do the declarative debugger tests. tests/debugger/Mmakefile: For each target, make the corresponding target in the 'declarative' subdirectory. WORK_IN_PROGRESS: Document the new (incomplete) feature. |
||
|
|
2bbf02daaf |
Use the same method of input for the browser as for the internal
Estimated hours taken: 5 Use the same method of input for the browser as for the internal tracer. Previously, the browser did input via the Mercury library and the internal tracer did input via readline (if available). This did not work properly if files were redirected into stdin, which meant that test cases could not be written for the browser. This change also adds a test case. browser/util.m: Add a predicate, util__trace_getline/4, which does input via the same method used by the internal debugger. browser/parse.m: Call util__trace_getline/4 instead of io__read_line/3. browser/browse.m: Pass the prompt to browser/parse.m as a string, rather than printing it before calling. trace/mercury_trace_internal.c: trace/mercury_trace_internal.h: Declare MR_trace_getline extern. runtime/mercury_init.h: runtime/mercury_wrapper.c: runtime/mercury_wrapper.h: util/mkinit.c: Make MR_trace_getline available to the browser via a function pointer. tests/debugger/Mmakefile: Add the new test case. tests/debugger/browser_test.m: tests/debugger/browser_test.inp: tests/debugger/browser_test.exp: The new test case. runtime/mercury_trace_base.c: runtime/mercury_trace_base.h: Export MR_tracing_not_enabled() for use by browser/util.m. |
||
|
|
526e5b9efe |
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.
|
||
|
|
5b9f441aa2 |
Add some hard-coded dependencies on queens.{dep,depend},
Estimated hours taken: 0.1
tests/debugger/Mmakefile:
Add some hard-coded dependencies on queens.{dep,depend},
since these are needed for the mdb_command_test test.
|
||
|
|
90c295d644 |
Disable the `queens' test, since currently we don't pass it if
Estimated hours taken: 0.1 tests/debugger/Mmakefile: Disable the `queens' test, since currently we don't pass it if readline support is enabled. |
||
|
|
0a7b4cf015 |
Work around some problems with egcs-1.1b getting internal
Estimated hours taken: 0.25 tests/debugger/Mmakefile: Work around some problems with egcs-1.1b getting internal errors on alpha-dec-osf3.2 when compiling certain queries in grade reg.gc. |
||
|
|
df486b6dc3 |
Pass the appropriate options to ensure that queens.m
Estimated hours taken: 0.25 tests/debugger/Mmakefile: Pass the appropriate options to ensure that queens.m is compiled with shared libraries on Linux. This is necessary because interactive queries only work if you use shared libraries. |
||
|
|
af082736c0 |
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/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. |
||
|
|
7157f97ba6 |
Add `MLFLAGS=--trace', since my earlier change to
Estimated hours taken: 0.1 tests/debugger/Mmakefile: Add `MLFLAGS=--trace', since my earlier change to `scripts/ml.in' means that this is now required. |
||
|
|
a6b007be78 |
Fix a bug: one of the "1>&2" redirections was in the wrong place.
Estimated hours taken: 0.1 tests/debugger/Mmakefile: Fix a bug: one of the "1>&2" redirections was in the wrong place. |
||
|
|
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. |
||
|
|
ebd6ddbf8f |
Set MERCURY_SUPPRESS_MDB_BANNER in the Mmakefile rather than
Estimated hours taken: 0.25 tests/debugger/Mmakefile: tests/debugger/runtests: Set MERCURY_SUPPRESS_MDB_BANNER in the Mmakefile rather than in the runtests script, so that `mmake check' works. |
||
|
|
a45acffcbb |
Fix a cut-and-paste error: the hard-coded dependencies for
Estimated hours taken: 0.05 tests/debugger/Mmakefile: Fix a cut-and-paste error: the hard-coded dependencies for existential_type_class.out were wrong. |
||
|
|
beaa554171 |
Extend the layout scheme to handle typeinfos inside typeclass infos,
Estimated hours taken: 16
Extend the layout scheme to handle typeinfos inside typeclass infos,
and thus enable the debugger (and later native gc) to work with programs
that use type classes and existential types.
compiler/llds.m:
Change the data structure that holds information about the locations
of the typeinfo variables of the tvars active at call return sites
from set(pair(tvar, lval)) to map(tvar, set(layout_locn)).
The change from set to map avoids the possibility of inadvertently
duplicating the info for a give type variable.
The change to explicitly keep a set of locations in which the typeinfo
var may be found allows us to use set intersection on those sets if
(a) the program point may be reached via more than one path, and
(b) not all paths have the same sets. Both of these can happen in
programs that use type classes.
The change from lval to layout_locn (which encodes either an lval,
or an lval representing a typeclass info and an (indirect) offset
inside that typeclass info) is necessary support programs with
type classes.
compiler/continuation_info.m:
Change the data structure that holds information about the locations
of the typeinfo variables of the tvars active at a particular program
point the same way and for the same reasons as in llds.m.
Take set intersections of typeinfo var locations whenever we find
multiple live variable info records for the same label.
compiler/call_gen.m:
Delay the construction of the return live variable information
until the code generator state has been updated to reflect where
things will be on return, instead of trying to cobble up this
info into the code generator state that reflects the point just
before the call. Apart from being cleaner, this is necessary
to avoid compiler aborts for programs that use existential types.
The old compiler could not find the typeinfos of any existentially
quantified type vars, since they do not exist before the call.
compiler/code_info.m:
Rewrite and generalize the code for generating live value information.
compiler/trace.m:
Remove the specialized code for generating live value information;
call code_info instead.
compiler/stack_layout.m:
Pick one of several possible locations for a typeinfo var.
Generate the new indirect layout location descriptions.
Reduce the number of tag bits used to describe different kinds of
lvals, to leave more room for the indirect information.
compiler/*.m:
Conform to the above data structure changes.
compiler/hlds_pred.m:
Clarify the documentation of type_info_locn.
runtime/mercury_stack_layout.h:
Update the section that deals with MR_Live_Lval to take
indirect typeinfo locations into account.
runtime/mercury_layout_util.c:
Handle indirect typeinfo locations when interpreting layout structures.
runtime/mercury_layout_util.c:
trace/mercury_trace_internal.c:
Ignore variables whose names start with TypeClassInfo.
runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
Add markers to remind Tyson to handle indirect typeinfo locations.
tests/debugger/implied_instance.{m,inp,exp}:
tests/debugger/multi_paramster.{m,inp,exp}:
tests/debugger/existential_type_classes.{m,inp,exp}:
Copies of the tests in tests/hard_coded/typeclasses, modified to
avoid or delay I/O, so that the calls to I/O preds that may or may
not be traced to do not affect the output.
tests/debugger/Mmakefile:
Add the new test cases.
Remove references to the *_lib variants of the old test cases.
They are not necessary if I/O is delayed until after the last
reported trace event.
tests/hard_coded/typeclasses/Mmakefile:
Remove --trace deep from existential_type_classes, since that
aspect of the test case is now covered in the debugger directory.
|
||
|
|
16f3d4ccaa |
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.
|
||
|
|
8ddce575d4 |
Introduce two new directories, trace and browser, containing libraries
Estimated hours taken: 10
Introduce two new directories, trace and browser, containing libraries
holding the C and Mercury code of the debugger respectively. (Although
the browser directory does not have a browser in it yet, the browser
should soon become its biggest component.) Take the opportunity to
rename the existing libraries, for consistency.
After this change, the linking order becomes:
the object of the auto-generated init file
program object files
trace library (libmer_trace.a)
browser library (libmer_browser.a)
standard library (libmer_std.a)
runtime library (libmer_rt.a)
Boehm collector (libgc.a)
To avoid circularities, libraries cannot contain direct calls to
any routines that are defined in libraries (or object files) that
occur earlier in the above list. Any such calls must be made into
indirect calls via function pointers.
In particular, there was a circularity caused by the library calling
MR_trace() which invokes the tracer which in turn invokes the
library. This circularity was broken by having MR_trace(),
which is defined in the runtime, call the tracer indirectly via
a global variable named MR_trace_func_ptr. This global variable
is initialized by the auto-generated *_init.c file.
To avoid linking in the tracer even when it is not being used,
this global variable is only set to point to MR_trace_real()
if you're using a debugging grade or if c2init was invoked
with the `-t' flag. Otherwise it is set to MR_trace_fake()
which just prints an error message telling the user to
rebuild the executable with debugging enabled.
Makefile.DLLs:
Reserve random locations for the two new libraries. Whether they work
will be decided by testing on Windows.
Mmake.common.in:
Add variables naming the new directories, and create variables
naming the libraries.
Mmakefile:
Add targets for the new directories, and modify existing rules
as appropriate.
browser/Mmakefile:
Mmakefile for the new directory, modelled on library/Mmakefile.
browser/browser_library.m:
Umbrella file for the new directory, modelled on library/library.m.
{browser,library}/debugger_interface.m:
Moved this file from library to browser without change.
browser/help.m:
A new module for the help system of the debugger. Not yet used.
compiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
compiler/mercury_compile.m:
If we are doing tracing, then pass -t instead of -i to c2init.
compiler/modules.m:
When generating the .dep file, get the grade flags passed to c2init.
doc/Mmakefile:
Remove the special treatment of library/debugger_interface.m.
library/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
library/library.m:
Do not import debugger_interface.
profiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
runtime/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
Remove references to files being moved to the trace directory.
runtime/mercury_init.h:
Refer to the automatically generated dll header file by its new name
(renamed because the runtime library is renamed).
Add declarations to support the new global variable MR_trace_func_ptr.
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_misc.c:
Remove inappropriate #includes of "mercury_trace.h", and substitute
a #include of "mercury_trace_base.h" if necessary.
{runtime,trace}/mercury_trace.[ch]:
{runtime,trace}/mercury_trace_external.[ch]:
{runtime,trace}/mercury_trace_internal.[ch]:
Move these files from the runtime to the trace directory.
The only changes are the removal from mercury_trace.h of declarations
added to runtime/mercury_trace_base.h, and the change from MR_trace
to MR_trace_real.
runtime/mercury_trace_base.[ch]:
Define MR_trace(), which does an indirect call through
MR_trace_func_ptr if the event should be traced.
Define MR_trace_fake, which just prints an error message.
Its address will be assigned to MR_trace_func_ptr if tracing
is not enabled.
Define the types needed by the signature of MR_trace.
Fix an old bug: s/MERCURY_TRACE_PERMANENT_H/MERCURY_TRACE_BASE_H/.
runtime/mercury_wrapper.[ch]:
Add the new global variable MR_trace_func_ptr.
scripts/c2init.in:
Add a new option, -t/--trace, which enables tracing by causing the
address of MR_trace_real to be assigned to MR_trace_func_ptr.
Have this option be implied by the grade. Also have the old option
-i (need initialization code) be implied by the grade, as well as by
-t.
scripts/ml.in:
Include the new libraries in the link command.
tests/debugger/Mmakefile:
Include -t instead of -i in the list of c2init options. (-t implies
-i.)
tools/bootcheck:
Copy and build the new directories as appropriate. The trace directory
is treated like the runtime, the browser directory is treated like the
library.
trace/Mmakefile:
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/mkinit.c:
Add the new option -t, as discussed above.
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/Mmakefile:
Specify -O0, since with the default optimization level, gcc on
cyclone ignores the assignment of TRUE to need_tracing when -t is
given (!!!).
|
||
|
|
ead9430de6 |
Disable the queens test, which is has output that doesn't
Estimated hours taken: 1.5 tests/debugger/Mmakefile: Disable the queens test, which is has output that doesn't seem to match its input. tests/invalid/Mmakefile: Generate dependencies for nested_impl_in_int, but don't try to build it any further. This detects the error, but avoids trying to build the entire program. |
||
|
|
f618936182 |
Fix bugs caused by recent changes to Mmake:
Estimated hours taken: 0.25 tests/invalid/Mmakefile: tests/hard_coded/Mmakefile: tests/term/Mmakefile: tests/debugger/Mmakefile: Fix bugs caused by recent changes to Mmake: s/$(MCFLAGS)/$(ALL_MCFLAGS)/ delete $(EXTRA_MCFLAGS) from definition of $(MCFLAGS) |
||
|
|
ce012270fb |
Change the tests for grade jump' and fast' so that they also
Estimated hours taken: 1 tests/valid/Mmakefile: tests/debugger/Mmakefile: Change the tests for grade `jump' and `fast' so that they also catch grades `jump.gc', `fast.gc', etc. |
||
|
|
4ada219856 |
Reorganize the label table to better fit the needs of accurate gc
Estimated hours taken: 25
Reorganize the label table to better fit the needs of accurate gc
and the tracer, and reduce the size of executables.
With these changes, the size of hello world, compiled with static
Mercury libraries but dynamic C libraries, goes from 150+ Kb to
138+ Kb, much of which is beyond our control (e.g. Boehm gc).
runtime/mercury_label.[ch]:
The old label table contained both entry labels and internal labels,
even though they had different kinds of layouts associated with them
(proc layouts and label layouts respectively). The two kinds of labels
have different usage patterns. Internal labels are needed for stack
walking, which requires random access by exact label address. Entry
labels are needed for finding which procedure a program counter is in
for accurate GC, which requires lower-bound inexact search.
The module now has two separate data structures for the two
different kinds of labels. Internal labels are in a hash table,
as before. Entry labels are in an array (resized on demand),
which is sorted for binary search. The entry label array and
its associated functions are present only if they are needed.
runtime/mercury_goto.h:
Call the new functions in mercury_label.c from the
init_{local,label,entry}{,_sl} macros.
runtime/mercury_misc.[ch]
Use the new functions in mercury_label. Fix some software rot,
so that the code now compiles with MR_DEBUG_GOTOS. (It still does not
compile with MR_LOWLEVEL_DEBUG, but the fix for that would conflict
with Tom's planned change to zone handling, so that fix should be
done after Tom is done.)
Note that mercury_misc.c still defines newmem() and oldmem()
although they are declared in mercury_std.h.
runtime/mercury_stack_trace.c:
Use the new functions in mercury_label. As a result, we also need
to make a few more pointers const.
runtime/mercury_table.[ch]:
Add a new traversal predicate to support a new function in
mercury_label.c. (That function is not used yet, but will be soon.)
runtime/mercury_trace.[ch]:
runtime/mercury_trace_base.[ch]:
Split the old mercury_trace module into two. The functions and
variables that will always be linked in (because they are referenced
from modules such as mercury_wrapper which are always needed) are
now in mercury_trace_base; the other functions and variables
stay in mercury_trace. This way, mercury_trace.o will be linked in
only if some module was compiled with execution tracing. Since
mercury_trace.o drags in mercury_trace_internal.o which drags in
everything needed for printing arbitrary terms (which is a lot),
this can be a significant win.
runtime/Mmakefile:
Include the new module in the library.
runtime/mercury_wrapper.c:
runtime/mercury_conf_param.h:
Remove some obsolete MERCURY_OPTIONS options, which would be
difficult to support with the new label table.
Move the #ifdefs around the -P option, so that programs not
compiled with MR_THREAD_SAFE will accept but ignore the option,
instead of aborting with the usage message.
Replace the long usage message for malformed MERCURY_OPTIONS
environment variables with a pointer to the user's guide.
This saves about 1 Kb on every executable.
runtime/mercury_conf_param.h:
Document MR_STACK_TRACE_THIS_MODULE.
util/mkinit.c:
Add a new flag, -i. If this flag is given, include the initialization
code regardless of grade. If it is not given, include the init code
only if the grade requires it.
The -i should be given if you want the executable to support stack
tracing, or uplevel printing in execution tracing, at the cost of
making the executable link in the init functions of all the modules
in the library.
Put the option handling code in alphabetical order.
Fix the wrong default name of the entry point. (It only worked because
c2init was always overriding the default.)
scripts/c2init.in:
Pass through the -i flag to mkinit.
Put the option handling code in alphabetical order.
compiler/mercury_compile.m:
If the trace level specifies any kind of tracing, pass -i to c2init.
tests/debugger/Mmakefile:
Add -i to the c2init flags.
tests/debugger/*
Update the other half the test cases (those which assume a traced
library) to conform to the changes in the debugger interface.
The first half were updated earlier.
doc/user_guide.texi:
In the environment variable section, modify the entry for
MERCURY_OPTIONS to document all the options it makes sense
for non-developers to use.
Slight changes to two other parts of the guide to reduce duplication
with the new material.
|
||
|
|
ced8c9b3ff |
Update the error message about invalid `--trace' arguments
Estimated hours taken: 0.25 compiler/handle_options.m: Update the error message about invalid `--trace' arguments to reflect the new names. tests/debugger/Mmakefile: Change `--trace full' to `--trace all' to reflect the new names for `--trace' arguments. |
||
|
|
d10af74168 |
This change introduces interface tracing, and makes it possible to successfully
Estimated hours taken: 50
This change introduces interface tracing, and makes it possible to successfully
bootstrap the compiler with tracing (either interface or full).
compiler/options.m:
Change the bool options --generate-trace into a string option --trace
with three valid values: minimal, interface and full. The last two mean
what they say; the intention is that eventually minimal will mean
no tracing in non-tracing grades and interface tracing in tracing
grades.
compiler/globals.m:
Add a new global for the trace level.
compiler/handle_options.m:
Convert the argument of --trace to a trace level.
Use only consistent 4-space indentation in the deeply nested
if-then-else.
compiler/trace.m:
Implement interface tracing.
Rename trace__generate_depth_reset_code as trace__prepare_for_call,
since it does more than reset the depth if this module is compiled
with interface tracing.
Do not check whether tracing is enabled before calling MR_trace;
let MR_trace make the check. This trades increased non-tracing
execution time for a substantial code size reduction (which may
in turn benefit execution time).
compiler/call_gen.m:
Call trace__generate_depth_reset_code by its new name.
compiler/code_info.m:
Fix a bug in the handling of non/semi commits. When entering a commit,
we used to push a clone of whatever the top failure continuation was.
However, the resume setup for this continuation could have started
with a label that assumed that the resume vars were in their original
locations (which are often registers), whereas the method of
backtracking to that point only guarantees the survival of stack slots,
not registers.
(This bug caused two lines of incorrect code to be generated among
the approx 30 million lines of code in the stage 2 compiler when
compiled with tracing.)
Fix another bug (previously untriggered as far as I know) in the
handling of multi/det commits. This one was breaking the invariant
that the resume vars set of each entry on the failure continuation
stack included the resume vars set of every other entry below it,
which meant that the values of these resume vars were not guaranteed
to be preserved.
compiler/stack_layout.m:
Make layout structures local to their module. They are not (yet)
referred to by name from other modules, and by declaring them
to be global we caused their names to be included even in stripped
executables, adding several megabytes to the size of the binary.
(The names are not stripped because a dynamically linked library
may want to refer to them.)
Change the mercury_data__stack_layout__ prefix on the names of
generated globals vars to just mercury_data__layout__. It is now
merely too long instead of far too long.
Include the label number in the label layout structure and the number
of typeinfo variables in a var_info structure only with native gc.
Their only use is in debugging native gc.
Fix some documentation rot.
compiler/llds.m:
Add a new field to the pragma_c instruction that says whether the
compiler-generated C code fragments access any stack variables.
compiler/frameopt.m:
Use the new field in pragma_c's to avoid a bug. Because frameopt was
assuming that the pragma_c instruction that filled in the stack slots
containing the call sequence number and depth did not access the stack,
it moved the pragma_c before the incr_sp that allocates the frame
(it was trying to get it out of the loop).
compiler/*.m:
Minor changes to set or ignore the extra field in pragma_c, to refer
to layout structures via the new prefix, or to handle the --trace
option.
doc/user_guide.texi:
Update the documentation for --trace.
runtime/mercury_types.h:
Add the type Unsigned.
runtime/mercury_goto.h:
Use the shorter layout prefix.
runtime/mercury_stack_layout.h:
Use the shorter layout prefix, and include the label number only with
native gc.
runtime/mercury_trace.[ch]:
runtime/mercury_trace_internal.[ch]:
runtime/mercury_trace_external.[ch]:
runtime/mercury_trace_util.[ch]:
Divide the old mercury_trace.[ch] into several components, with one
module for the internal debugger, one for the interface to the
external debugger, one for utilities needed by both. Mercury_trace.c
now has only the top-level stuff that steers between the two
debuggers.
runtime/mercury_trace.[ch]:
Add the new global variable MR_trace_from_full. Before each call,
the calling procedure assigns TRUE to this variable if the caller
is fully traced, and FALSE otherwise. Interface traced procedures
generate trace events only if this variable is TRUE when they are
called (fully traced callee procedures ignore the initial value of
the variable).
Make MR_trace return immediately without doing anything unless
tracing is enabled and a new extra argument to MR_trace is TRUE.
This extra argument is always TRUE for trace events in fully traced
procedures, while for trace events from interface traced procedures,
its value is set from the value of MR_trace_from_full at the time
that the procedure was called (i.e. the event is ignored unless the
interface traced procedure was called from a fully traced procedure).
runtime/mercury_trace.[ch]:
runtime/mercury_trace_internal.[ch]:
For global variables that are stored in stack slots, make their type
Word rather than int.
Use a new function MR_trace_event_report instead of calling
MR_trace_event with a NULL command structure pointer to indicate
that the event is to be reported but there is to be no user
interaction.
Use %ld formats in printfs and casts to long for better portability.
runtime/mercury_trace_internal.c:
Save trace-related globals across calls to Mercury library code
in the debugger, since otherwise any trace events in this code
could screw up e.g. the event number or the call number sequence.
Create separate functions for printing port names and determinisms.
runtime/mercury_wrapper.h:
Disable the tracing of the initialization and finalization code
written in Mercury.
runtime/Mmakefile:
Update for the new source and header files.
tests/debugger/{debugger_regs,interpreter,queens}_lib.{m,inp,exp}:
One new copy of each existing test case. These ones are intended
to be used when the stage 2 library is compiled with tracing, which
affects the tests by adding events for the library procedures called
from the test programs.
The .m files are the same as before; one of the .inp files is a bit
different; the .exp files reflect the correct output when the library
is compiled with full tracing.
tests/debugger/Mmakefile:
Provide separate targets for the new set of test cases.
Use --trace full instead of --generate-trace.
tests/debugger/runtests:
Try both the new set of test cases if the old set fails, and report
failure only if both sets fail. This is simpler than trying to figure
out which set should be really tested, and the probability of a false
positive is negligible.
|
||
|
|
564d358da3 |
Avoid about half of the slow "mmake realclean"s required by a bootcheck.
Estimated hours taken: 0.5
Avoid about half of the slow "mmake realclean"s required by a bootcheck.
tests/*/runtests:
Concentrate all the actions performed before the test and after
a successful tests (both of which involve an "mmake realclean")
into two scripts, tests/{startup,shutdown}.
tests/shutdown:
Clean up the directory, and touch the file CLEAN.
tests/startup:
If the file CLEAN exists and is the most recent file in the directory,
consider the directory clean to beging with. Otherwise, run mmake
realclean.
|
||
|
|
5cdc719376 |
Include EXTRA_MCFLAGS in MCFLAGS, instead of just overriding
Estimated hours taken: 0.1 tests/debugger/Mmakefile: Include EXTRA_MCFLAGS in MCFLAGS, instead of just overriding MCFLAGS totally. |
||
|
|
67d8308260 | Same as previous message. |