Estimated hours taken: 0.25
browser/.cvsignore:
library/.cvsignore:
profiler/.cvsignore:
runtime/.cvsignore:
trace/.cvsignore:
Update the .cvsignore files to work under linux.
Estimated hours taken: 1
browser/Mmakefile:
compiler/Mmakefile:
library/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
trace/Mmakefile:
util/Mmakefile:
Simplify the code by deleting unnecessary uses of $(EXTRA_*), etc.
This is now handled once and for all in scripts/Mmake.vars, and
so it doesn't need to be separately handled by */Mmakefile.
This patch also fixes an annoyance where if you set EXTRA_CFLAGS,
the flags that you set were being passed to mgnuc twice.
Estimated hours taken: 6
If calling from the internal debugger, use readline input for the
interactive term browser and interactive queries.
browser/browse.m:
Change some if-then-elses to switches, which will help
catch errors if a new functor is added to the debugger type.
browser/parse.m:
browser/util.m:
Return a string from util__trace_getline/4 rather than a
list of chars, which saves converting from a string to a list
of chars and then back again.
browser/util.m:
Add a version of util__trace_getline that also takes I/O
stream arguments. Pass these arguments to MR_trace_getline.
browser/declarative_oracle.m:
Call util__trace_getline/4 to do input via readline (if
available). Improve error handling.
browser/interactive_query.m:
Call util__trace_getline to get user input, instead of
standard library predicates.
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
Add two I/O stream arguments to MR_trace_getline.
Estimated hours taken: 20
Incorporate the term brower stuff in the external debugger.
browser/browse.m:
Define browse__browse_external() which is the same as browse__browse()
but for the case where the term browser is called from the external
debugger.
Add an argument in predicates that need it to indicate whether the term
browser was called from the external or the internal debugger.
Define write_string_debugger/4, nl_debugger/3, write_int_debugger/4,
print_format_debugger/4 predicates and call them in place of
io__write_string/4, io__nl/3, io__write_int/4, and io__print/4
respectively. If the term browser is called from the internal debugger,
those predicates call the predicates they replace; otherwise, they
send their argument to the socket via a term of type
term_browser_response.
browser/debugger_interface.m
Define a new debugger request `browse/1'.
Define get_variable_name/2 that allows to retrieve from
mercury_trace_external.c the name of the variable to browse.
browser/parse.m:
Define parse__read_command_external/3 that parses the browser command
sent through the socket.
runtime/mercury_layout_util.c:
trace/mercury_trace_internal.c:
Move the definition of MR_trace_find_var() and
MR_trace_validate_var_count() from mercury_trace_internal.c to
mercury_layout_util.c to make it available to the external debugger.
runtime/mercury_layout_util.h:
trace/mercury_trace_internal.c:
Move the definition of MR_Var_Spec_Kind and MR_Var_Spec from
mercury_trace_internal.c to mercury_layout_util.h to make it
available to mercury_layout_util.c.
trace/mercury_trace_browse.ch:
Define the function MR_trace_browse_external() which is the same
as MR_trace_browse() except it uses the external debugger socket
instead of mdb_in and mdb_out.
trace/mercury_trace_external.c:
Define MR_trace_browse_one_external(), MR_trace_browse_var_external()
which are the same as MR_trace_browse_one() and MR_trace_browse_var()
of mercury_trace_internal.c, but for the use of the external debugger.
Define MR_get_variable_name() that calls get_variable_name/2 defined
in debugger_interface.m.
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.
Estimated hours taken: 12
Clean up the declarative debugger.
browser/declarative_debugger.m:
browser/declarative_oracle.m:
- Add a new type, oracle_data, to store the oracle database.
- Thread an oracle database through a single call to the
front end.
- Replace `unknown' with a less overloaded name in
some type definitions.
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
browser/declarative_debugger.m:
- Improve documentation.
browser/declarative_debugger.m:
- Export new type, edt_truth.
- Improve the interface to the oracle.
- Add a new typeclass, evaluation_tree, and update the
previous interface to reflect this.
- Make declarative_bug a polymorphic type, and change the
constructor for buggy nodes from `wrong' to `e_bug'.
Estimated hours taken: 11
This change allows interactive queries to be typed from the external debugger.
browser/debugger_interface.m:
Define new debugger requests: query/1, cc_query/1, io_query/1 and
mmc_options/1.
Define 2 new procedures that are used in trace/mercury_trace_external.c:
get_list_modules_to_import/3 retrieves from a *query/1 request a list
of modules to be imported; and get_mmc_options/2 retrieves from a
mmc_options/1 request the option to pass to mmc to compile the query.
browser/interactive_query.m:
Define a new procedure query_external/7 that does the same job as
query/7 but for the external debugger.
Unset the environment variable `MERCURY_OPTIONS' before compiling a
query; `MERCURY_OPTIONS' is exported before executing a program under
the control of Opium-M (and mdb) and is not supposed to be set before
compiling a program.
trace/mercury_trace_browse.ch:
Add a new function MR_trace_query_external() to interface the
ML_query_external() function defined by browser/interfactive_query.m.
trace/mercury_trace_external.c:
Add code to implement new commands `query', `cc_query', `io_query',
and `mmc_options', using the MR_trace_query_external() function defined
by trace/mercury_trace_browse.h.
trace/mercury_trace_external.h:
Export MR_debugger_socket_in and MR_debugger_socket_out since there
are needed in interactive_query.m.
doc/user_guide.texi:
Add a comment to tell that there exists duplicated documentation betwenn
Opium-M/source/interactive_queries.op and doc/user_guide.texi and to
tell me to update it if someone update the documentation here.
Estimated hours taken: 36
Switch to a closure representation that includes runtime type and procedure id
information, so that closures can be copied, garbage collected, printed, etc.
This RTTI information is not yet used. Adding code to use it would be futile
until Tyson finishes his changes to the other RTTI data structures.
Note also that this change provides the information required for solving the
problem of trying to deep copy closures only for grades that include
--typeinfo-liveness. Providing this info for other grades is future work.
configure.in:
Find out what the right way to refer to a variable-sized array
at the end of a struct is.
runtime/mercury_ho_call.h:
New file to define the structure of closures and macros for accessing
closures.
runtime/Mmakefile:
Add the new header file.
runtime/mercury_ho_call.c:
Add an entry point to handle calls to new-style closures. The code
to handle old-style closures, which was unnecessarily duplicated for
each code model, stays until all the installed compilers use the new
closure representation.
Until that time, the new entry point will contain code to detect
the use of old-style closures and invoke the old code instead.
This allows stage1s compiled with old compilers to use the old style
and stage2 to use the new style without any special tricks anywhere
else.
Add a new entry point to handle method calls of all code models.
The old entry points, which had the same code, will also be deleted
after this change has been bootstrapped.
runtime/mercury_calls.h:
Remove the macros that call closures. Their interface sucked, they
were not used, and their implementation is now out of date.
runtime/mercury_stack_layout.h:
Add a new type, MR_Type_Param_Locns, for use by the C type
representing closures. Since MR_Stack_Layout_Vars has a field,
MR_slvs_tvars, which references a data structure identical
in every way to MR_Type_Param_Locns, change the type of that field
to this new type, instead of the previous cheat.
runtime/mercury_layout_util.h:
Minor update to conform to the new type of the MR_slvs_tvars field.
(This is the only use of that field in the system.)
runtime/mercury_type_info.h:
Add new types MR_TypeInfo and MR_PseudoTypeInfo. For now, they
are just Word, but later we can make them more accurate.
In the meantime, we can refer to them instead of to Word,
making code clearer. One such reference is now in mercury_ho_call.h.
compiler/notes/release_checklist.html:
Add a reminder to remove the redundant code from mercury_ho_call.c
after bootstrapping.
compiler/llds.m:
Replace three code addresses for calling closures and another three
for calling methods with one each.
compiler/call_gen.m:
compiler/dupelim.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/llds_out.m:
Trivial updates in accordance with the change to llds.m
compiler/code_info.m:
Move the code to handle layouts to continuation_info.m,
since that's where it belongs. Leave only the code for picking
up parameters from code_infos and for putting results back in there.
Remove the redundant arguments of code_info__init, and extract
them from ProcInfo, to make clear that they are related.
compiler/code_gen.m:
Since we pass ProcInfo to code_info__init, don't pass its components.
compiler/continuation_info.m:
Add the code moved from code_info.m, in a form which takes explicit
arguments for things that used be hidden in the code_info.
Add new code, closely related to the moved code, that creates
layout info from a procedure's argument info, rather than from a
(part of) the current code generator state. This way, it can be
invoked from places that don't have a code_info for the procedure
for which they want to generate layouts. This is the case when
we generate layouts for closures.
compiler/par_conj_gen.m:
compiler/trace.m:
Minor changes required by the move of stuff from code_info to
continuation_info.
compiler/stack_layout.m:
Export some predicates for use by unify_gen.
compiler/unify_gen.m:
Switch to creating new style closures, complete with layout info.
Optimize the code for extending closures a bit. By copying the
fixed words of the closure outside the loop, we avoid incurring
the loop overhead twice.
compiler/code_util.m:
Add a couple of utility predicates for continuation_info.m and
unify_gen.m
library/benchmarking.m:
library/std_util.m:
Refer to the new entry point for handling closures.
browser/dl.m:
Use the new closure representation.
Note that extras/dynamic_linking/dl.m, which is supposed to be
the same as browser/dl.m but is not, should also be updated, but
this will be handled later by Fergus.
tests/hard_coded/closure_extension.{m,exp}:
A new test case to exercise the code for extending closures.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 2
Add the option `--enable-decl-debug' to configure, which enables
declarative debugging support in the internal debugger.
configure.in:
Add the option to configure.
browser/declarative_debugger.m:
runtime/mercury_wrapper.c:
Avoid using MR_address_of_edt_root_node unless configured
for declarative debugging.
runtime/mercury_conf.h.in:
runtime/mercury_conf_param.h:
Move the configuration macro to mercury_conf.h.in.
trace/mercury_trace_declarative.c:
Define MR_edt_root_node only if configured for declarative
debugging, thereby undoing a previous change.
Estimated hours taken: 3
Fix a bug causing the debugger tests to get link errors.
browser/declarative_debugger.m:
Call MR_edt_root_node indirectly via MR_address_of_edt_root_node.
runtime/mercury_wrapper.{c,h}:
Add a global function pointer, MR_address_of_edt_root_node.
util/mkinit.c:
Make sure MR_address_of_edt_root_node is initialized.
trace/mercury_trace_declarative.c:
Define MR_edt_root_node even if the declarative debugger is not
used.
Estimated hours taken: 80
Add a front end to the declarative debugger, written in Mercury. Modify
the back end to call this whenever an EDT is built. Also, various
bug fixes and improvements.
browser/declarative_debugger.m:
New module. This is a first implementation of the front end of
the declarative debugger. It uses a simple top-down algorithm
to search the EDT for a buggy node. The results are printed
in a simple format to the output stream. It is called from the
back end, in trace/mercury_trace_declarative.c.
browser/declarative_oracle.m:
New module. This is a first implementation of an oracle for the
declarative debugger. It simply passes all queries directly
on to the user.
browser/browser_library.m:
Import the new modules.
trace/mercury_trace_declarative.c:
- Various fixes/improvements of comments.
- Fix bugs where `int' is used instead of `Unsigned'.
- Pass the event_info structure to MR_trace_decl_update_path,
rather than passing various components of it.
- Use the copy of MR_trace_event_number in the event_info structure
rather than referring to the global variable directly.
- Remove the EDT printing functions, as they have been superseded by
the new front end. Call the new front end instead of these old
functions.
- Provide an interface to the EDT nodes that is imported by the
front end.
- Ensure that, after diagnosis, we end up at the same event we
started at.
- Fix a bug where it was assumed all procedures had at least one
argument.
- Ensure that the user is notified if the dd_wrong operation cannot
be started due to MR_trace_retry failing.
trace/mercury_trace_declarative.h:
- Move a #include to the correct place.
- Declare the interface to the EDT nodes.
trace/mercury_trace_internal.c:
Fix a bug introduced earlier.
runtime/mercury_conf_param.h:
Add a new configuration macro, MR_DEBUG_DD_BACK_END. When defined
this causes information about the declarative debugger back end
to be printed out during operation.
Estimated hours taken: 2
Simplify the Mmakefiles. Fix a few minor latent bugs.
*/Mmakefile:
- Factor out some common code by defining a new variable M_ENV
which holds settings of environment variables for mmc, mgnuc, etc.
- For consistency, always override MERCURY_C_ALL_INCL_DIRS rather
than passing extra `-I' options to mgnuc.
- Make sure to always include `$(BOEHM_GC)/include' in the search path,
so that it will work if we try to compile with `-O6'.
- Make sure to always include `--cflags $(ALL_CFLAGS)' in MCS, so
that the EXTRA_CFLAGS etc. will get passed down to gcc via mmc.
- Make sure that the Mmakefiles in all directories set
all the MC* variables: MCPI, MCSI, MCOI, MCTOI, etc.
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.
Estimated hours taken: 0.5
boehm_gc/Mmakefile:
browser/Mmakefile:
compiler/Mmakefile:
doc/Mmakefile:
library/Mmakefile:
runtime/Mmakefile:
scripts/Mmakefile:
Separated out all the commands to create installation directories
into a single target in each Mmakefile, upon which all targets which
used to create directories depend. This avoids a race condition
with parallel installs into a new directory tree, whereby two or
more `mkdir -p' commands simultaneously try to create the same
missing path component, resulting in all but one failing.
Estimated hours taken: 17
Add support for invoking interactive queries to mdb.
browser/interactive_query.m:
New module, to implement interactive queries.
browser/dl.m:
browser/name_mangle.m:
Copy these files from extras/dynamic_linking, since
they are needed by browser/interactive_query.m.
configure.in:
runtime/mercury_conf.h.in:
Autodetect the presence of support for dlopen() etc.
browser/dl.m:
Add #ifdefs so that the code will compile (but report
an error at runtime) if dlopen() etc. are not supported.
browser/browser_library.m:
Add interface_query, dl, and name_mangle to the list of
modules in this library.
trace/mercury_trace_browse.h:
trace/mercury_trace_browse.c:
Add a new function MR_trace_query() to interface to the ML_query()
function defined by browser/interfactive_query.m.
trace/mercury_trace_internal.c:
Add code to implement new commands `query', `cc_query', `io_query',
and `mmc_options', using the MR_trace_query() function defined by
trace/mercury_trace_browse.h.
runtime/mercury_grade.h:
Add code to define MR_GRADE_OPT, so that browser/interactive_query.m
can use this to invoke mmc with the same grade that the executable
being debugged was built with.
doc/mdb_categories:
doc/user_guide.texi:
Document the new commands `query', `cc_query', `io_query',
and `mmc_options'.
Estimated hours taken: 1
Avoid a two-three second delay in the printing of (the top levels of) large
data structures such as module_infos in the debugger.
browser/browse.m:
Instead of computing the exact size of the term when we check whether
we can print it in full, compute the size only up to the maximum,
and skip the rest. This lets us avoid traversing 99+% of typical
module_infos.
Estimated hours taken: 5
Generalized the code in the external debugger in order to be able to handle
inter-module inlining and compiler-generated procedures. To handle the former,
I have added the definition module as a slot to the event structure. To handle
the later, I have split output_current_slots() (and found_match()) into two
different functions; one for user defined events, the other one for compiler
generated events.
trace/mercury_trace_external.c:
browser/debugger_interface.m
Split output_current_slots() into output_current_slots_user() and
output_current_slots_comp()
Idem for found_match(), found_match_user() and found_match_comp().
Add a slot in the event for the definition module name in the case of
user-defined event.
Estimated hours taken: 1
Add a pred_or_func attribute to the Mercury event for the external debugger
that indicates if the current procedure is a function or a predicate.
browser/debugger_interface.m:
trace/mercury_trace_external.c:
Add a slot in MR_found_match() and MR_output_current_slots() for the
pred_or_func attribute.
runtime/mercury_stack_layout.h.
Add a comment to say that The MR_PredFunc enummeration should EXACTLY
match the definition of the `pred_or_func' type in
browser/debugger_interface.
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.
Estimated hours taken: 10
This change implement the retry command for the external debugger.
trace/mercury_trace.[ch]:
trace/mercury_trace_internal.[ch]:
Move MR_trace_retry() and MR_trace_find_input_arg() from
mercury_trace_internal.c to mercury_trace.c since they are also needed
in the external debugger.
MR_trace_retry() now returns a `char *' pointer which is either
NULL if the retry proceeds correctly or an error message if it fails.
trace/mercury_trace_internal.h:
trace/mercury_trace.h:
Move the definition of the type MR_Event_Details from
mercury_trace_internal.h to mercury_trace.h since both are also
needed in the external debugger.
Idem for the constant MR_INIT_ARG_COUNT.
trace/mercury_trace.c:
trace/mercury_trace_external.[ch]:
MR_trace_external() now returns a code address to jump in.
Pass the integer max_mr_num in argument of MR_trace_external() since
it is needed by MR_trace_retry().
Add a MR_send_message_to_socket_format() that allows to send formated
message to the socket. I need that because the error message send to the
socket must be a prolog term.
trace/mercury_trace_external.c:
Implement the retry command in MR_trace_event_external().
browse/debugger_interface.m:
Add support for the retry port.
Make all the lines fits in 80 colums.
Estimated hours taken: 1
Part 2 of adding support to mdb for doing the debugger I/O in
a different window to the I/O of the program being debugged:
ensure that the browser I/O goes to the debugger I/O streams.
browser/browse.m:
Undo Tyson's changes to add the I/O streams to the browser
state. Instead, add I/O streams as extra arguments to
browse__browse and browse__print.
trace/mercury_trace_browse.c:
Convert the debugger I/O streams from FILE* to MercuryFile*
and pass them to browse__browse and browse__print.
trace/mercury_trace_internal.h:
trace/mercury_trace_internal.c:
Export the variables holding the mdb I/O streams,
for use by mercury_trace_browser.c.
Estimated hours taken: 0.25
browser/browse.m:
Print the output to stdout rather than stderr,
for consistency with the rest of mdb's output,
and to avoid breaking all the test cases in
tests/debugger.
Estimated hours taken: 8
Add support for exceptions to the debugger, and
add support for debugging to the exception module.
browser/debugger_interface.m:
Add `exception' to the trace_port_type enumeration.
runtime/mercury_trace_base.h:
Add MR_PORT_EXCEPTION to the MR_Trace_Port enumeration.
trace/mercury_trace_internal.c:
trace/mercury_trace.h:
trace/mercury_trace.c:
Modify the code to handle MR_PORT_EXCEPTION.
extras/exceptions/exception.m:
- Define stack layout structures for the hand-written procedures
`builtin_throw' and `builtin_catch'.
- Use mktempframe() rather than mkframe() to allocate the temporary
frames used to prevent hijacking of the exception-catching frame
(this is more efficient, and avoids the need to give a stack
layout for those frames).
- Change the code for builtin_throw/1 so that if MR_trace_enabled
is true, it calls a new function trace_throw(), which calls
MR_trace(..., MR_PORT_EXCEPTION, ...) for each stack frame.
- Fix some type errors occurring for non-GC grades.
- Fix some uses of obsolete names (e.g. replace `hp' with `MR_hp').
runtime/mercury_trace_base.c:
compiler/trace.m:
Add some comments relating to the above changes.
Estimated hours taken: 3
Fix a bug in the debugger -- the term printing wasn't working after
you had changed the output stream -- output would be sent to the
program's output stream instead of the debugger's output stream.
browser/browse.m:
Fix the output and input streams used for the term browser.
Estimated hours taken: 2.75
Change the mdb `print' command so that it invokes the non-interactive
version of the term browser, and change the way the browser is invoked
so that the browser state is preserved across multiple invocations
of `print' or `browse' in a single mdb session.
browser/browse.m:
Make `browser_state' an abstract type.
Add new predicate `browse__init_state' to initialize that ADT.
Change the interface to `browse__browse' so that it takes and
returns the old and new browser_states.
Add a new predicate `browse__print' to replace the old
`browse__portray_root' predicate; this is the non-interactive
version of the browser. It calls io__write_univ if the term
is small enough, and browse__portray (with flat format) otherwise.
Export the `browse__print' and `browse__init_state' predicates to C.
Delete the predicates for formatting terms as strings, since that
code was a potential double-maintenance problem and was not needed.
library/io.m:
Export `io__write_univ', for use by browser/browse.m.
trace/mercury_trace_browse.h:
trace/mercury_trace_browse.c:
New files. These provide an interface to the browser
which preserves the browser state in a C static variable.
trace/Mmakefile:
Add the new files mercury_trace_browse.{h,c} to the appropriate
file lists.
trace/mercury_trace_internal.c:
Change the `browse' and `print' mdb commands to use the new
functions defined in mercury_trace_browse.{h,c} rather than
calling browser__browse and io__print (respectively), and don't
print a newline afterwards, since the browser does that itself.
Delete the old hack to avoid printing out HLDS and ModuleInfo,
since it's not necessary any more.
doc/user_guide.texi:
Update the documentation for the `browse' and `print' commands
to reflect these changes.
tests/debugger/*.exp:
tests/debugger/*.exp2:
Update the expected output from the debugger to reflect these changes.
Estimated hours taken: 2
Add an mdb command to invoke the term browser.
trace/mercury_trace_internal.c:
Add code to implement a new command `browse', which invokes
the interactive term browser in browser/browse.m.
doc/mdb_categories:
doc/user_guide.texi:
Document the new `browse' mdb command.
Also simplify the documentation on the `print' command.
browser/browse.m:
Change browse/3 so that it takes an argument of type `T' rather
than `univ'.
library/std_util.m:
Modify ML_expand() so that it does not abort for values of type
c_pointer, type_info, or array(T). This is to prevent the
browser from aborting when trying to display values of those types.
Estimated hours taken: 40
Add a simple term browser for use by the trace-based debugger.
This is minimal but useful browser. Not included in this version
are a scripting language, Windows Explorer-style tree expansion,
and other features not yet thought of.
N.B. This still needs to be hooked into the debugger.
browser/Mmakefile:
Added target browse_test.
browser/browser_library.m:
Added modules required for the browser.
browser/browse_test.m:
A simple driver for the browser with an example
data structure to browse. (new file)
browser/browse.m:
The browser proper. (new file)
browser/parse.m:
Parser for browser's command language. (new file)
browser/util.m:
Miscellaneous utilities used in the browser code. (new file)
browser/frame.m:
Bare minimal ASCII graphics frames. (new file)
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.
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 (!!!).