Estimated hours taken: 12
Get the debugger to sort variables better.
trace/mercury_trace_vars.[ch]:
A new module to manage the debugger's information about the variables
live at the current program point (which can be defined as the
combination of a specific event and an ancestor level).
This new module centralizes the management of the (sorted) list of
current variables. This in turn allows us to use a better sorting
method, one that orders VarName15 correctly wrt both VarName2 and
VarName.
The new module also uses the type, not the name, of a variable
to decide whether to exclude it from the list of variables
that may be presented to the user (e.g. if it is a typeinfo
or a typeclassinfo).
trace/mercury_trace_internal.c:
trace/mercury_trace_external.c:
Use the new module's facilities. This factors out some "mostly"
common code.
trace/Mmakefile:
Add the new module.
runtime/mercury_layout_util.[ch]:
Remove the code recently moved here from trace/mercury_trace_internal,
as well as the filtered versions of some functions, since they are
not needed anymore.
Move the code for MR_make_var_list to trace/mercury_trace_external,
since that is the only place where it is used (or is at all likely
to be used). Since its new home is next to several very similar
functions, this should also reduce the probability that any required
maintenance will be overlooked. Also alter its coding style to conform
to its new neighbours.
Move the definition of MR_Var_Spec to trace/mercury_trace_vars.h.
tests/debugger/*.exp:
Update the expected output files. In most cases, this is just because
the new module outputs different white space, but in some cases, it
also reflects that the debugger now prints variables in a different
order.
Estimated hours taken: 2
trace/mercury_trace_internal.c:
GNU readline always echos the inputs, so if readline support is
enabled, then ignore the MR_echo_commands variable,
and report an error if the user tries to use `echo off'.
Also, if we're not using readline, then echo the `echo on' command,
so that the output will be the same as with readline.
tests/debugger/*.inp:
Ensure that `echo on' is always the first command.
tests/debugger/*.exp:
tests/debugger/*.exp2:
Update to reflect the changes to *.inp,
and to include the echo of the `echo on' command.
(Also delete the mdb intro banners from *_lib.exp*,
because mdb is invoked with MERCURY_SUPPRESS_MDB_BANNER=yes.
The *_lib* files are in fact currently not used, so they should
probably be just deleted, I think. But I'll do that as
a separate change.)
Estimated hours taken: 4.5
Implement demangling for instance declarations (i.e. base_typeclass_infos).
compiler/base_typeclass_info.m:
compiler/llds_out.m:
Change the way name mangling for base_typeclass_infos is done
to ensure that they can be unambiguously demangled.
util/mdemangle.c:
profiler/demangle.m:
Add code to demangle base_typeclass_infos.
util/mdemangle.c:
Fix a bug: if it got part way through demangling a symbol
before noticing that it had the wrong format, then it would
sometimes print out a partially demangled version of the
symbol rather than printing out the original symbol unchanged.
tests/debugger/*.exp*:
Update the expected output to reflect the new mangling scheme.
(Really the debugger ought to demangle the names, but
currently it doesn't.)
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.