mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-22 21:03:53 +00:00
083d376e6598628362ee91c2da170febd83590f4
127 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a06ae2c6ef |
Simplify the code of the mdb help system.
browser/help.m:
Simplify the data types representing the nested structure
of help information. Simplify the code of the predicates
that work on that structure.
Simplify some of the predicates, e.g. by having a search predicate
do *just* search.
Give types and predicates more meaningful names. Make argument order
more suitable for state-variables. Move a predicate next to its
only call site.
browser/declarative_user.m:
Conform to the change in help.m.
Replace two bools with values of bespoke types.
browser/declarative_debugger.m:
browser/declarative_oracle.m:
Conform to the changes in help.m and declarative_user.m.
doc/generate_mdb_doc:
Fix the vim modeline.
trace/mercury_trace_declarative.c:
trace/mercury_trace_help.c:
Conform to the changes in the browser directory.
util/info_to_mdb.c:
Switch from /**/ to // for comments.
Give a macro a meaningful name.
Fix indentation.
|
||
|
|
d465fa53cb |
Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
|
||
|
|
53b573692a |
Convert C code to use // style comments.
runtime/*.[ch]:
trace/*.[chyl]:
As above. In some places, improve comments, e.g. by expanding contractions
such as "we've". Add #ifndef guards against double inclusion around
the trace/*.h files that did not already have them.
tools/*:
Make the corresponding changes in shell scripts that generate .[ch] files
in the runtime.
tests/*:
Conform to a slight change in the text of a message.
|
||
|
|
94535ec121 |
Fix spelling and formatting throughout the system.
configure.ac: browser/*.m: compiler/*.m: deep_profiler/*.m: library/*.m: ssdb/*.m: runtime/mercury_conf.h.in: runtime/*.[ch]: scripts/Mmake.vars.in: trace/*.[ch]: util/*.c: Fix spelling and doubled-up words. Delete trailing whitespace. Convert tabs into spaces (where appropriate). |
||
|
|
233b899714 |
Avoid some C compiler warnings in the trace directory.
trace/mercury_trace.h:
Avoid a warning from the C compiler about casting -1 to an enum
by adding bool next to the enum that says whether the enum is actually
defined, or is supposed to be set later (the latter is what the cast -1
meant).
trace/mercury_trace_cmds.h:
Rename the type MR_Trace_Command_Info to MR_TraceCmdTableEntry,
since this (a) says more about the values of the type, (b) avoids
confusion with the separate MR_TraceCmdInfo type (the one that
contained the enum mentioned above), and (c) avoids combining
underscores with CamelCase.
trace/mercury_trace_spy.c:
Avoid some warnings about switches on enums specifying -1 as a case.
trace/mercury_trace.c:
trace/mercury_trace_*.[ch]:
Conform to the above changes.
|
||
|
|
31d3897e22 |
Thread-safe alternative to strerror.
Add MR_strerror as a thread-safe alternative to strerror. The current implementation wraps strerror_r(), strerror_s() or sys_errlist as appropriate for the platform. Bug #340. configure.ac: runtime/mercury_conf.h.in: Check for strerror_r, strerror_s. Delete irrelevant code in the sockets test for the external debugger. runtime/mercury_runtime_util.c: runtime/mercury_runtime_util.h: Add MR_strerror and use it. library/io.m: Use MR_strerror. In particular, mercury_output_error was not thread-safe. Pass errno to mercury_output_error explicitly for clarity. Delete req_lock parameter in ML_maybe_make_err_msg macro which is not needed any more. compiler/prog_event.m: runtime/mercury_deep_profiling.c: runtime/mercury_misc.c: runtime/mercury_term_size.c: runtime/mercury_trace_base.c: trace/mercury_trace_cmd_developer.c: trace/mercury_trace_cmd_exp.c: trace/mercury_trace_cmd_misc.c: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_internal.c: Use MR_strerror. compiler/notes/coding_standards.html: Update coding standard. extras/net/sockets.m: extras/net/tcp.m: Use MR_strerror. NEWS: Announce change. |
||
|
|
6851f943ec |
Avoid C compiler warnings that occur when using clang with -Wall.
Except where noted otherwise below most of these warnings relate to implicit conversions between 64- and 32-bit integers or the signedness of integers differing in spots. library/construct.m: Delete an unused local variable in the implementation of get_functor_lex. library/bitmap.m: The function MR_bitmap_cmp returns an MR_Integer not an int. library/thread.semaphore.m: Change the count field of the ML_SEMAPHORE_STRUCT structure into an MR_Integer (which is what gets passed in). trace/mercury_trace_declarative.c: Avoid a warning about fprintf being called where its second argument is not a string literal. (In this case it can be replaced by a call to fputs.) library/io.m: mdbcomp/rtti_access.m: trace/mercury_trace.c: trace/mercury_trace_cmd_breakpoint.c: trace/mercury_trace_cmd_help.c: trace/mercury_trace_completion.m: trace/mercury_trace_declarative.[ch]: trace/mercury_trace_external.c: trace/mercury_trace_internal.c: trace/mercury_trace_source.c: trace/mercury_trace_tables.c: trace/mercury_trace_vars.c: util/info_to_mdb.c: util/mfiltercc.c: util/mdemangle.c: util/mkinit.c: util/mkinit_erl.c: util/mkinit_common.h: util/mkinit_common.c: As above. |
||
|
|
5faf8d88c7 |
Delete unused local variables in the trace library.
trace/mercury_trace.c: trace/mercury_trace_cmd_breakpoint.c: trace/mercury_trace_cmd_browsing.c: trace/mercury_trace_cmd_dd.c: trace/mercury_trace_cmd_developer.c: trace/mercury_trace_declarative.c: trace/mercury_trace_help.c: trace/mercury_trace_internal.c: trace/mercury_trace_spy.c: trace/mercury_trace_tables.c: trace/mercury_trace_vars.c: As above. |
||
|
|
2ccac171dd |
Add float registers to the Mercury abstract machine, implemented as an
Branches: main Add float registers to the Mercury abstract machine, implemented as an array of MR_Float in the Mercury engine structure. Float registers are only useful if a Mercury `float' is wider than a word (i.e. when using double precision floats on 32-bit platforms) so we let them exist only then. In other cases floats may simply be passed via the regular registers, as before. Currently, higher order calls still require the use of the regular registers for all arguments. As all exported procedures are potentially the target of higher order calls, exported procedures must use only the regular registers for argument passing. This can lead to more (un)boxing than if floats were simply always boxed. Until this is solved, float registers must be enabled explicitly with the developer only option `--use-float-registers'. The other aspect of this change is using two consecutive stack slots to hold a single double variable. Without that, the benefit of passing unboxed floats via dedicated float registers would be largely eroded. compiler/options.m: Add developer option `--use-float-registers'. compiler/handle_options.m: Disable `--use-float-registers' if floats are not wider than words. compiler/make_hlds_passes.m: If `--use-float-registers' is in effect, enable a previous change that allows float constructor arguments to be stored unboxed in structures. compiler/hlds_llds.m: Move `reg_type' here from llds.m and `reg_f' option. Add stack slot width to `stack_slot' type. Add register type and stack slot width to `abs_locn' type. Remember next available float register in `abs_follow_vars'. compiler/hlds_pred.m: Add register type to `arg_loc' type. compiler/llds.m: Add a new kind of lval: double-width stack slots. These are used to hold double-precision floating point values only. Record setting of `--use-float-registers' in exprn_opts. Conform to addition of float registers and double stack slots. compiler/code_info.m: Make predicates take the register type as an argument, where it can no longer be assumed. Remember whether float registers are being used. Remember max float register for calls to MR_trace. Count double width stack slots as two slots. compiler/arg_info.m: Allocate float registers for procedure arguments when appropriate. Delete unused predicates. compiler/var_locn.m: Make predicates working with registers either take the register type as an argument, or handle both register types at once. Select float registers for variables when appropriate. compiler/call_gen.m: Explicitly use regular registers for all higher-order calls, which was implicit before. compiler/pragma_c_gen.m: Use float registers, when available, at the interface between Mercury code and C foreign_procs. compiler/export.m: Whether a float rval needs to be boxed/unboxed when assigned to/from a register depends on the register type. compiler/fact_table.m: Use float registers for arguments to predicates defined by fact tables. compiler/stack_alloc.m: Allocate two consecutive stack slots for float variables when appropriate. compiler/stack_layout.m: Represent double-width stack slots in procedure layout structures. Conform to changes. compiler/store_alloc.m: Allocate float registers (if they exist) for float variables. compiler/use_local_vars.m: Substitute float abstract machine registers with MR_Float local variables. compiler/llds_out_data.m: compiler/llds_out_instr.m: Output float registers and double stack slots. compiler/code_util.m: compiler/follow_vars.m: Count float registers separately from regular registers. compiler/layout.m: compiler/layout_out.m: compiler/trace_gen.m: Remember the max used float register for calls to MR_trace(). compiler/builtin_lib_types.m: Fix incorrect definition of float_type_ctor. compiler/bytecode_gen.m: compiler/continuation_info.m: compiler/disj_gen.m: compiler/dupelim.m: compiler/exprn_aux.m: compiler/global_data.m: compiler/hlds_out_goal.m: compiler/jumpopt.m: compiler/llds_to_x86_64.m: compiler/lookup_switch.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/par_conj_gen.m: compiler/proc_gen.m: compiler/string_switch.m: compiler/tag_switch.m: compiler/tupling.m: compiler/x86_64_regs.m: Conform to changes. runtime/mercury_engine.h: Add an array of fake float "registers" to the Mercury engine structure, when MR_Float is wider than MR_Word. runtime/mercury_regs.h: Document float registers in the Mercury abstract machine. Add macros to access float registers in the Mercury engine. runtime/mercury_stack_layout.h: Add new MR_LongLval cases to represent double-width stack slots. MR_LONG_LVAL_TAGBITS had to be increased to accomodate the new cases, which increases the number of integers in [0, 2^MR_LONG_LVAL_TAGBITS) equal to 0 modulo 4. These are the new MR_LONG_LVAL_TYPE_CONS_n cases. Add max float register field to MR_ExecTrace. runtime/mercury_layout_util.c: runtime/mercury_layout_util.h: Extend MR_copy_regs_to_saved_regs and MR_copy_saved_regs_to_regs for float registers. Understand how to look up new kinds of MR_LongLval: MR_LONG_LVAL_TYPE_F (previously unused), MR_LONG_LVAL_TYPE_DOUBLE_STACKVAR, MR_LONG_LVAL_TYPE_DOUBLE_FRAMEVAR. Conform to the new MR_LONG_LVAL_TYPE_CONS_n cases. runtime/mercury_float.h: Delete redundant #ifdef. runtime/mercury_accurate_gc.c: runtime/mercury_agc_debug.c: Conform to changes (untested). trace/mercury_trace.c: trace/mercury_trace.h: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_internal.c: trace/mercury_trace_spy.c: trace/mercury_trace_vars.c: trace/mercury_trace_vars.h: Handle float registers in the trace subsystem. This is mostly a matter of saving/restoring them as with regular registers. |
||
|
|
eccc863e7d |
Add comments about my recent design decision about the representation
Estimated hours taken: 0.1 Branches: main runtime/mercury_stack_layout.h: trace/mercury_trace_declararative.c: Add comments about my recent design decision about the representation of goal paths. |
||
|
|
a83aad6681 |
Remove references to nondet foreign_proc from the definition of the data
Estimated hours taken: 2 Branches: main Remove references to nondet foreign_proc from the definition of the data structures that define stack layouts. runtime/mercury_stack_layout.h: Remove the trace ports that could occur in nondet foreign_procs from the definition of the trace port type used in C code. mdbcomp/prim_data.m: Remove the trace ports that could occur in nondet foreign_procs from the definition of the trace port type used in Mercury code. compiler/layout_out.m: compiler/stack_layout.m: compiler/trace_params.m: mdbcomp/trace_counts.m: runtime/mercury_trace_base.h: trace/mercury_trace_declarative.h: Delete references to those ports. runtime/mercury_stack_layout.h: Update the binary compatibility version number for debuggable executables, since the port number of user events has changed. |
||
|
|
2ddbac45bc |
When the declarative debugger is about to search in the
supertree of the starting node and there has been no interaction with the user yet show a warning and ask the user if the search should continue in ancestor calls (bug #20). This could happen when the user issues the dd command at a node whose descendents are all trusted. In this case the declarative debugger will begin searching in the ancestors of the node where the dd command was issued, which can seem unintuitive. The warning message should help the user understand what is going on. browser/declarative_debugger.m: Add a warn_if_searching_supertree flag to the declarative debugger state. This flag is initially set to yes and is changed to no after a user interaction. Print a warning if a supertree is requested and there has been no interaction with the user yet. Ask the user if the search should continue in the supertree. Add a predicate to perform per-session initialization. This currently resets the warn_if_searching_supertree flag. browser/declarative_oracle.m: browser/declarative_user.m: Add get_user_input_stream functions. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/all_trusted.exp: tests/debugger/declarative/all_trusted.exp2: tests/debugger/declarative/all_trusted.inp: Include the warning message in the expected output. tests/debugger/declarative/supertree_warning.exp: tests/debugger/declarative/supertree_warning.inp: tests/debugger/declarative/supertree_warning.m: New test case. trace/mercury_trace_cmd_dd.c: Do per-session initialization. trace/mercury_trace_declarative.c: trace/mercury_trace_declarative.h: Add a wrapper function to call the new session initialization predicate. |
||
|
|
99b9d15442 |
Fix a warning from the C compiler.
Estimated hours taken: 0.1 Branches: main trace/mercury_trace_declarative.c: Fix a warning from the C compiler. |
||
|
|
53286dd4bf |
Implement a new compiler option, --exec-trace-tail-rec, that preserves direct
Estimated hours taken: 30
Branches: main
Implement a new compiler option, --exec-trace-tail-rec, that preserves direct
tail recursion in det and semidet procedures even when debugging is enabled.
This should allow the debugging of programs that previously ran out of stack.
The problem arose because even a directly tail-recursive call had some code
after it: the code for the EXIT event, like this:
p:
incr_sp
fill in the usual debug slots
CALL EVENT
...
/* tail call */
move arguments to registers as usual
call p, return to p_ret
p_ret:
/* code to move output arguments to right registers is empty */
EXIT EVENT
decr_sp
return
If the new option is enabled, the compiler will now generate code like this:
p:
incr_sp
fill in the usual debug slots
fill in new "stack frame reuse count" slot with 0
CALL EVENT
p_1:
...
/* tail call */
move arguments to registers as usual
update the usual debug slots
increment the "stack frame reuse count" slot
TAILCALL EVENT
goto p_1
The new TAIL event takes place in the caller's stack frame, so that the local
variables of the caller are available. This includes the arguments of the
recursive call (though if they are unnamed variables, the debugger will not
show them). The TAIL event serves as a replacement for the CALL event
of the recursive invocation.
compiler/options.m:
Add the new option.
compiler/handle_options.m:
Handle an implication of the new option: the declarative debugger
does not (yet) understand TAIL events.
compiler/mark_tail_calls.m:
New module to mark directly tail recursive calls and the procedures
containing them as such.
compiler/hlds.m:
compiler/notes/compiler_design.html:
Mention the new module.
compiler/mercury_compile.m:
Invoke the new module when the new option asks us to.
compiler/hlds_goal.m:
Add the feature used to mark tail recursive calls for the debugger.
Rename an existing feature with a similar but not identical purpose
to avoid possible confusion.
compiler/hlds_pred.m:
Add a field to proc_infos that says whether the procedure contains
tail recursive calls.
Minor style improvements.
compiler/passes_aux.m:
Minor change to accommodate the needs of the new module.
compiler/code_info.m:
Transmit the information from mark_tail_calls to the code generator.
compiler/call_gen.m:
Implement the new option.
compiler/trace_gen.m:
Reserve the extra slot needed for the new option.
Switch to state variable notation in the code that does the slot
allocation, since this is less error-prone than the previous approach.
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
Remember what stack slot holds the stack frame reuse counter,
for transmission to the runtime system.
compiler/proc_gen.m:
Add the new label needed for tail recursion.
Put the arguments of some procedures into a more logical order.
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/saved_vars.m:
compiler/table_gen.m:
Conform to the changes above.
compiler/trace_params.m:
mdbcomp/prim_data.m:
runtime/mercury_trace_base.[ch]:
Add the new event type.
Convert mercury_trace_base.h to four-space indentation.
runtime/mercury_stack_layout.h:
Add a field to the execution trace information we have for each
procedure that gives the number of the stack slot (if any) that holds
the stack frame reuse counter. Add a macro to get the value in the
counter.
Convert this header file to four-space indentation.
runtime/mercury_stack_trace.[ch]:
When walking the stack, we now have to be prepared to encounter stack
frames that have been reused. Modify the algorithms in this module
accordingly, and modify the interfaces of the exported functions
to allow the functions' callers to behave accordingly as well.
Group the information we gather about stack frame for printing into
one structure, and document it.
Convert the header to four-space indentation.
library/exception.m:
mdbcomp/trace_counts.m:
Conform to the changes above.
In trace_counts.m, fix an apparent cut-and-paste error (that hasn't
caused any test case failures yet).
trace/mercury_trace.c:
Modify the implementation of the "next" and "finish" commands
to accommodate the possibility that the procedure at the selected
depth may have had its stack frame reused. In such cases
tests/debugger/tailrec1.{m,inp,exp,data}:
A new test case to check the handling of tail recursive procedures.
|
||
|
|
519d8f9508 |
Fix a bug in the handling of I/O actions by the debugger: the procedural
Estimated hours taken: 12
Branches: main
Fix a bug in the handling of I/O actions by the debugger: the procedural
debugger didn't implement the documented commands for printing I/O actions.
Also implement some new variants of the print commands to make it easier
to print I/O actions.
Also track down and pinpoint a bug that caused the declarative debugger
to ask questions from *outside* the tree it was asked to debug, as shown
by this example from a new test case compiled in a decldebug grade (so that
the library, and thus io.read, gets compiled with deep, not shallow tracing):
-----------------------------------------------------------------------------
mdb ./io_read_bug
1: 1 1 CALL pred io_read_bug.main/2-0 (cc_multi) io_read_bug.m:22
I/O tabling started.
mdb> g 4
Please input the number of queens and a period:
4: 3 2 CALL pred io.read/3-0 (det) io.m:4240 (io_read_bug.m:24)
mdb> f
5.
513: 3 2 EXIT pred io.read/3-0 (det) io.m:4240 (io_read_bug.m:24)
mdb> dd
[1, 3, 5, 2, 4]
main(_, _)
31 tabled IO actions: too many to show
Valid?
-----------------------------------------------------------------------------
browser/declarative_tree.m:
Put an XXX at the spot of the second bug.
browser/declarative_analyser.m:
browser/declarative_debugger.m:
Change the formatting of some code to give consistent and more
meaningful names to some arguments, and to make switches easier
to read. There are no algorithmic changes.
runtime/mercury_trace_base.[ch]:
Move the code for disabling/enabling deep profiling to the code that
does disabling/enabling of I/O actions, to put all relevant actions
for entering and leaving Mercury code together.
Note the similarity of MR_turn_debug_off/MR_turn_debug_back_on
with MR_TRACE_CALL_MERCURY, and make the similarity even greater
by adding the code for disabling/enabling deep profiling to
MR_TRACE_CALL_MERCURY (without which the deep profiler data structures
would have been screwed up by the declarative debugger).
Add a const qualifier to an argument.
trace/mercury_trace_cmd_browsing.c:
Fix the first bug: update the code of the "print" and "browse" mdb
commands to implement their documented capabilities with respect to
printing I/O actions.
Add a new capability: "print io" (or "print action") will now print
a bunch of I/O actions, starting with the first available one, and on
successive invocations will print successive bunches. This is an easy
way to print all I/O actions (without being overwhelmed by a huge
printout if there are too many).
Add a new capability: "print io limits" will now print the numbers of
the first and last I/O actions.
doc/user_guide.texi:
Document the new capabilities.
trace/mercury_trace_declarative.c:
Fix the second bug: disable debugging and then restore the old state
around calls to Mercury code from the declarative debugger.
My guess is that the bug was introduced when we gave declarative
debugging its own trace function; the one it used to share with
the procedural debugger still does the same disable/restore pair.
trace/mercury_trace_internal.c:
Delete the code now moved to mercury_trace_base.c.
trace/mercury_trace_util.[ch]:
Add a utility function for use by the new code in
mercury_trace_cmd_browsing.c, and increase robustness by more
precise representation of unsigned values.
trace/mercury_trace_cmd_dd.c:
Cosmetic fixes.
tests/debugger/declarative/tabled_read_decl.m:
Update this test case to our current coding standards. There are no
changes in the code.
tests/debugger/declarative/tabled_read_decl.{inp,out}:
Test the bug fixes by printing out a bunch of I/O actions.
tests/debugger/declarative/builtin_call_rep.exp:
Update this expected output file to conform for my recent change to
procedure representations.
tests/debugger/declarative/io_read_bug.{m,inp,exp}:
A new test case that exposes the second bug above. The .inp file
exposes the bug; the .exp file is a dummy.
tests/debugger/declarative/Mmakefile:
Add the new test case, but don't enable it yet.
tests/debugger/print_io_actions.{m,inp,exp,data}:
A new test case to test the new "print io" variant of the print
command.
tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
Enable the new test case.
tests/EXPECT_FAIL_TESTS.asm_fast.gc.decldebug:
Expect the big_array_from_list test to fail in decldebug grades,
since we in that grade we can never get tail recursion, even in the
standard library.
|
||
|
|
e33ca246a5 |
Move the code for reading procedure representations from the browser directory
Estimated hours taken: 0.2 Branches: main Move the code for reading procedure representations from the browser directory (in declarative_execution.m) to the mdbcomp directory (the file program_representation.m) in order to make it accessible for the deep profiler, since future changes by Paul Bone will require this. browser/declarative_execution.m: mdbcomp/program_representation.m: Make the move. Turn a semidet function into a predicate. Update some old constructs. mdbcomp/program_representation.m: mdbcomp/slice_and_dice.m: Change the prefix on the functions exported to C to MR_MDBCOMP from the previous mixture of MR_MDB and ML. trace/*.c: Conform to the new prefixes on exported C functions. |
||
|
|
5e7d665e9f |
Add a --reset-knowledge-base option to the mdb `dd' command. The new option
resets the declarative debugger's knowledge base of previous question answers. NEWS: Mention the new option. Move an item that was in the wrong place. browser/declarative_debugger.m: browser/declarative_oracle.m: Export a procedure to reset the oracle's knowledge base. doc/user_guide.texi: Document the new option. tests/debugger/declarative/oracle_db.exp: tests/debugger/declarative/oracle_db.inp: Test the new option. trace/mercury_trace_cmd_dd.c: trace/mercury_trace_declarative.c: trace/mercury_trace_declarative.h: Add the new option. |
||
|
|
ebb805a2d3 |
Currently, all disjuncts from a disjunction generate an event with the same
Estimated hours taken: 3 Branches: main Currently, all disjuncts from a disjunction generate an event with the same port: MR_PORT_DISJ. However, the declarative debugger treats first disjuncts differently from later ones, and the g12 visualizer will want this distinction too. Therefore this diff splits MR_PORT_DISJ into two: MR_PORT_DISJ_FIRST and MR_PORT_DISJ_LATER. (The visualizer will also probably want to know when the disjunction is complete, but it is not yet known whether this should be done as a separate port type for the last disjunct or a new kind of event that happens when execution backtracks out of the disjunction overall, so we hold off for now.) runtime/mercury_trace_base.[ch]: Make the split described above. Move the user-visible names of ports from the source file to the header file to make them easier to maintain. Update the list of places that need to be updated when the list of ports is changed. Have two sets of names for trace ports: one that uniquely identifies each port, and one that conflates MR_PORT_DISJ_FIRsT and MR_PORT_DISJ_LATER. The first is for use by automatic tools, the second is for presentation to humans (so that mdb output, for example, remains the same.) Put some parts of the header file in a more logical order. browser/declarative_execution.m: mdbcomp/prim_data.m: mdbcomp/trace_counts.m: compiler/layout_out.m: trace/mercury_trace_internal.m: trace/mercury_trace_tables.m: Conform to the above changes. compiler/trace_params.m: Conform to the above changes. Start numbering ports from 0, since C enums start from 0. This change has no repercussions since we don't yet have any code that depends on the details of the encoding. compiler/trace_gen.m: Decide which kind of disj event to create. trace/mercury_trace_declarative.c: Handle first and later disjuncts separately. |
||
|
|
d66ed699a1 |
Add fields to structures representing the C code itself that says whether
Estimated hours taken: 4 Branches: main Add fields to structures representing the C code itself that says whether or not the C code affects the liveness of lvals. This is intended as the basis for future improvements in the optimization of such code. Implement a new foreign_proc attribute that allows programmers to set the value of this field. Eliminate names referring to `pragma c_code' in the LLDS backend in favor of names referring to foreign_procs. compiler/llds.m: Make the changes described above. Consistently put the field containing C code last in the function symbols that contain them. compiler/prog_data.m: Make the changes described above. Rename some other function symbols to avoid ambiguity. compiler/prog_io_pragma.m: Parse the new foreign_proc attribute. doc/reference_manual.texi: Document the new attribute. compiler/pragma_c_gen.m: Rename the main predicates. compiler/opt_util.m: Change some predicates into functions, for more convenient invocation. compiler/livemap.m: Rename the predicates in this module to avoid ambiguity and the need for module qualification. compiler/*.m: Conform to the changes above. |
||
|
|
b61ea9de44 |
Implement a large chunk of the code that was previously missing for .mmos
Estimated hours taken: 20 Branches: main Implement a large chunk of the code that was previously missing for .mmos grades. The system now correctly computes several answers for the tc_minimal test case, before going into an infinite loop (since the code for recognizing the absence of further solutions is not yet there). Significantly improve the infrastructure for debugging such changes. compiler/table_gen.m: Complete the mmos transformation. compiler/proc_gen.m: Handle the special return requirements of mmos generators, which must return not to a caller (since each generator is the root of its own SLD tree), but to a consumer in another SLD tree that is waiting for an answer. compiler/hlds_pred.m: Provide a mechanism whereby table_gen.m can communicate to proc_gen.m the requirement for this special return. compiler/trace_gen.m: When generating events, include the port and the goal path in a comment. This makes the generated C code significantly easier to understand. compiler/layout_out.m: Export a function for trace_gen.m to use. compiler/hlds_goal.m: Change goal_path_to_string to a function to make it easier to use. compiler/*.m: Conform to the change to goal_path_to_string. runtime/mercury_context.[ch]: In .mmos grades, include the current debugger call sequence number, depth, and event number in contexts, to be saved and loaded with the contexts. This allows each context to have its own separate sequence of events. This capability depends not directly on the grade, but on the macro MR_EXEC_TRACE_INFO_IN_CONTEXT. For now, this is defined only in .mmos grades, but in future, it may be useful in other grades as well. runtime/mercury_conf_param.h: Define and document MR_EXEC_TRACE_INFO_IN_CONTEXT. runtime/mercury_mm_own_stacks.[ch]: runtime/mercury_tabling_preds.h: Implement some predicates needed by the own stack transformation. Implement the code for generators returning answers to consumers, and the code for consumers scheduling generators when they need more answers. At the moment, the code for detecting when generators depend on each other is not yet written. Provide better facilities for debugging own stack minimal model grades. Fix a cut-and-paste bug (wrong macro name guarding the handwritten C module). runtime/Mmakefile: Rebuild only what needs to be rebuilt when mercury_tabling_preds.h changes. runtime/mercury_label.[ch]: Add a utility function for returning the name of an arbitrary label (internal or entry). Rename some fields to give them MR_ prefixes. Always define the functions for recording both entry and internal labels, even if they are not called from most modules, since they may be called from a few handwritten modules in the runtime. Rename a function to avoid a clash with the name of a macro, and thus allow the change to mercury_goto.h. runtime/mercury_goto.h: Fix a bug with MR_init_entry_an. This macro was supposed to always insert the entry label that is its argument into the entry table, but instead of calling the function it was meant to call, it called a macro that could be (and usually way) defined to expand to nothing. The fix is to call the function a different name than the macro, and to call the function, not the macro. runtime/mercury_wrapper.c: In own stack minimal model grades, create a main context separate from the current context, since the current context may be needed to hold a generator's state. Make MR_eng_this_context point to this context. Register all labels in the debugging variants of minimal model grades. runtime/mercury_accurate_gc.c: runtime/mercury_agc_debug.c: runtime/mercury_debug.c: library/exception.m: Conform to the change to runtime/mercury_label.h. runtime/mercury_stack_trace.c: Conform to the change to runtime/mercury_label.h. Document the link to trace/mercury_trace_internal.c. trace/mercury_trace.[ch]: trace/mercury_trace_cmd_forward.c: Split the GOTO command into two: STEP and GOTO. STEP always stops at the next event (without any test), even if it is in a different context (and possibly with a lower event number than the immediately previous event, since the event numbers in different contexts are not related). As before, GOTO always goes to the specified event number, but in .dmmos grades it can now be told that this event number should be matched only in a specified context. The specification is done by an extra argument specifying the short name of the context's generator; the ansence of such an argument means the main context. trace/mercury_trace_cmd_internal.c: In own stack grades, when the current context is that of a generator, print the subgoal the generator is working on before the event number, call depth, call sequence number and the rest of the event report. Document the link to runtime/mercury_stack_trace.c, which has similar code. trace/mercury_trace_cmd_external.c: trace/mercury_trace_cmd_declararive.c: Use the STEP command where GOTO was used for this simpler job, since this is (very slightly) faster. trace/mercury_trace_cmd_developer.c: Fix some bugs with handling own stack tables. doc/user_guide.texi: Document the new functionality of the goto mdb command. The documentation is commented out, since .mmos grades are for developers only at the moment. tools/lmc.in: Turn off C optimizations when C debugging is enabled. For some reason, the default value of --cflags-for-debug does not include -O0. |
||
|
|
87037824f6 |
Fix some departures from our coding style.
Estimated hours taken: 0.3
Branches: main
compiler/xml_documentation.m:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_type_info.h:
trace/mercury_trace_external.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_help.c:
Fix some departures from our coding style.
|
||
|
|
455e1eea75 |
The runtime had two different conventions for naming types.
Estimated hours taken: 2 Branches: main The runtime had two different conventions for naming types. One convention, used mostly in the debugger-related modules, added underscores between capitalized words; example: MR_Label_Layout. The other convention, used in most modules, used capitalized words without underscores (e.g. MR_TypeInfo). This diff standardizes on the second convention. It has no algorithmic changes, only renames of types. runtime/*.[ch]: trace/*.[ch]: compiler/*.m: library/*.m: mdbcomp/*.m: Effect the change described above. The only substantive change is that runtime/mercury_stack_layout.h used to define *two* types for trace levels: MR_TraceLevel and MR_Trace_Level, and this diff standardizes on just one (they had equivalent definitions). runtime/mercury_bootstrap.h: Add a #define from the old name to the new for all the changed type names that the installed compiler can put into .c files. We can delete these #defines some time after this diff has bootstrapped. slice/.mgnuc_opts: Restore the --no-mercury-stdlib-dir option, without which the slice directory won't compile after this change (because it looks for type names in the installed runtime header files, which define the old versions of type names). |
||
|
|
9ec86d6a6d |
The objective of this diff is to switch from a table of solver events built
Estimated hours taken: 32
Branches: main
The objective of this diff is to switch from a table of solver events built
into the compiler (and eventually the debugger) into a table of events
defined by a file provided by the user to the compiler, which the compiler
then records in the executable for use by the debugger.
The current design, for speed of implementation, uses temporary files parsed
by a bison-generated parser. Since the compiler needs to be able to invoke
the parser even if it is compiled in a non-debug grade, the parser is in
a new library, the eventspec library, that is always linked into the Mercury
compiler and is always linked into any Mercury program with debugging enabled
(but is of course linked only once into a Mercury compiler which has debugging
enabled).
Modify the debugger to give it the ability to print the attributes of
user-defined events (for now, only the non-synthesized attributes).
Implement a new debugger command, "user", which goes to the next user-defined
event.
configure.in:
Require flex and and bison to be available.
doc/user_guide.texi:
Document user defined events and the new debugger capabilities.
doc/mdb_categories:
Include "user" in the list of forward movement commands.
Fix some earlier omissions in that list.
runtime/mercury_stack_layout.h:
Include an event number in the user-defined event structure.
Include a string representing an event set specification in module
layout structures.
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.[ch]:
runtime/mercury_types.h
Switch from solver events to user events in names.
runtime/mercury_trace_term.[ch]:
Provide a representation of flat terms, for use in representing
the calls that generate synthesized attributes.
Ensure that exported field names have an MR_ prefix.
browser/cterm.m:
Conform to the change to runtime/mercury_trace_term.h.
scripts/c2init.in:
scripts/ml.in:
Include the eventspec library in programs compiled with debugging
enabled.
compiler/Mmakefile:
Include the eventspec library in the compiler.
compiler/options.m:
Add a new option, --event-spec-file-name, that allows the user to
specify the set of user-defined events the program may use.
compiler/handle_options.m:
Set this optimization from an environment variable (which may be
set by the mmc script) if the new option is not explicitly given.
compiler/prog_data.m:
Define the data structures for the compiler's representation of the
event set specification.
Move some definitions around to group them more logically.
compiler/hlds_module.m:
Include the event set specification as a new field in the module_info.
compiler/prog_event.m:
Add the code for invoking the parser in the eventspec library,
and for converting the simple term output by the parser to the
compiler own representation, which contains more information
(to wit, the types of the function attributes) and which has had
a whole bunch of semantic checks done on it (e.g. whether synthesized
attributes depend on themselves or on nonexistent attributes).
Provide a function to generate a canonicalized version of the event
specification file.
compiler/module_qual.m:
compiler/equiv_type.m:
Process event spec specifications as well as items, to module qualify
the names of the types of event arguments, and expanding out
equivalence types.
In equiv_type.m, rename some variables to make clear what kind of info
they represent.
compiler/mercury_compile.m:
Process the event set specification file if one has been selected:
read it in, module qualify it, expand its equivalence types, and add
to the module_info.
compiler/compile_target_code.m:
Include the event_spec library when linking debuggable executables.
compiler/call_gen.m:
compiler/continuation_info.m:
compiler/trace_gen.m:
compiler/trace_params.m:
mdbcomp/prim_data.m:
mdbcomp/trace_counts.m:
runtime/mercury_goto.h:
Generate user-defined events instead of solver events.
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
Include a canonicalized version of the event specification file
in the module layout if the module has any user-defined events.
compiler/code_info.m:
compiler/llds_out.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/typecheck.m:
Conform to the changes above.
compiler/passes_aux.m:
Rename a predicate to avoid an ambiguity.
trace/Mmakefile:
Add the definition and rules required to build the eventspec library.
trace/mercury_event_scanner.l:
trace/mercury_event_parser.y:
A scanner and a parser for reading in event spec specifications.
trace/mercury_event_spec_missing.h:
Provide the declarations that should be (but aren't) provided by
flex and bison.
trace/mercury_event_spec.[ch]:
The main module of the eventspec library. Provides functions to read
in event set specifications from a file, and to write them out as a
Mercury term in the form needed by the compiler.
trace/mercury_trace_tables.c:
If the module layouts being registered include event set
specifications, then check their consistency. Make the specification
and the consistency indication available to other modules.
trace/mercury_trace_internal.c:
During initialization, if the modules contain a consistent set of event
set specifications, then read that specification into the debugger.
(We don't yet make use of this information.)
Add an extra mdb command, "user", which goes forward to the next
user-defined event.
trace/mercury_trace.[ch]:
trace/mercury_trace_cmd_forward.[ch]:
Implement the new mdb command.
trace/mercury_trace_vars.[ch]:
For user-defined events, include the attributes' values among the
values that can be printed or browsed.
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_declarative.c:
Minor changes.
scripts/scripts/prepare_tmp_dir_grade_part:
Copy the .y and .l files to the tmp dir we use for installs.
tools/bootcheck:
Copy the .y and .l files of the trace directory to stage 2.
tools/lmc.in:
Include the eventspec library when linking debuggable executables.
tests/debugger/user_event.{m,inp,exp}:
tests/debugger/user_event_spec:
New test case to test the new functionality.
tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/completion.exp:
Expect the new "user" mdb command in the completion output.
|
||
|
|
2d25acf696 |
Change the representation of file streams in the io module so that they
Estimated hours taken: 25
Branches: main
Change the representation of file streams in the io module so that they
can be used as typeclass instances. This is not currently possible because
file streams are defined as equivalence types and making them typeclass
instances results in overlapping instances.
This diff changes the representation by putting notag wrappers around the
various file stream types: io.input_stream, io.output_stream,
io.binary_input_stream, etc. This avoids the problem with overlapping
instances. It also improves type-safety; it is now not possible to pass a
binary input stream where a binary output stream is expected and so forth.
This change is complicated by the fact that the io module interacts with both
the runtime and the debugger via the C interface. In order to preserve the
existing C interface that the io module presents to the runtime (the
alternative being to more or less change all the argument types to MR_Word),
the I/O operations that operate on file streams have been split into two
parts: a "typed" part that is exported from the io module and an "untyped"
part that deals with primitive streams (the io.stream type).
For the debugger the problem is the reverse since there we typically pass
values of type MercuryFilePtr to exported Mercury procedures. In order
to avoid warnings from gcc we add a set of macros to the runtime that
wrap or unwrap MercuryFilePtrs. There should be no performance impact
since the macros just expand to casts.
library/io.m:
Do not define the various I/O streams as equivalence types in order
to avoid problems with overlapping instances when these types are
used as typeclass instances.
Mark io.seek_binary/5 and io.binary_stream_offset/4 as obsolete.
Add a typeclass io.binary_stream and make both binary file stream
types instances of it. This is so that the above predicates will
continue to work until they are deleted.
Add new predicates: io.seek_binary_input/5, io.seek_binary_output/5
io.binary_input_stream_offset/4 and io.binary_input_stream_offset/4
to replace the above.
When using io.write to print file streams strip off the wrapper
before printing the entry from the stream database. The information
in the wrapper is redundant - we use that from the stream db since
that is more detailed.
Format some section headings to conform with our current coding
standard.
Lots of minor formatting changes.
runtime/mercury_init.h:
s/io.h/io.mh/ in a comment.
runtime/mercury_library_types.h:
Add macros to wrap (and in one case unwrap) file stream types
as we pass them across the C interface. This avoids warnings
from gcc.
browser/listing.m:
Upwrap the input stream passed to mercury_stream_to_c_FILE_star
before trying to extract the underlying C file pointer.
trace/mercury_trace_browse.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
Use the new macros in the runtime to wrap streams that we pass back to
Mercury procedures.
compiler/export.m:
Unrelated change: s/Word/MR_Word/
NEWS:
Announce the changes to the io module.
tests/debugger/declarative/io_stream_test.exp2:
Conform to the changes in the io module.
tests/hard_coded/Mmakefile:
tests/hard_coded/print_stream.{m,exp}:
Test for io.write and file streams.
tests/invalid/Mmakefile:
tests/invalid/mixed_up_streams.{m,err_exp}:
Test that it isn't possible to pass binary input streams where
binary output streams are expected.
tests/valid/Mmakefile:
tests/valid/file_stream_instances.m:
Add a test case to check that we can use the various file stream
types as typeclass instances.
|
||
|
|
863874df85 |
Document my recent change implementing coverage testing.
Estimated hours taken: 6 Branches: main Document my recent change implementing coverage testing. At the same time, eliminate the old hack that allowed a file containing a list of file names to be considered a trace count file. We haven't needed it since the addition of mtc_union, and it can lead to incomprensible error messages. (The presence of the old hack made documenting coverage testing harder.) In the process, fix the tools code for rerunning failed test cases only. doc/user_guide.texi: Document my recent change implementing coverage testing, and the elimination of the old hack. mdbcomp/trace_counts.m: Modify the predicates for reading in trace count files along the lines above. mdbcomp/slice_and_dice.m: Modify the predicates for reading in slices and dices along the lines above. Rename some function symbols to avoid ambiguities. compiler/tupling.m: slice/mcov.m: slice/mtc_diff.m: slice/mtc_union.m: trace/mercury_trace_declarative.c: Conform to the changes above. slice/mcov.m: Fix the usage message, which referred to this program by its old name mct. Allow the output to be restricted to a set of named modules only. This is to make testing easier. slice/mtc_diff.m: Rename the long form of the -o option from --out to --output-file, to make it consistent with the other programs. tests/run_one_test: tools/bootcheck: Modify the algorithm we use to gather trace counts for the Mercury compiler from both passed and failed test cases to run mtc_union periodically instead of gathering all the trace counts file and keeping them to the end (which takes far too much disk space). Fix an old bug: gather trace counts from executions of the Mercury compiler only. tests/debugger/Mmakefile: tests/debugger/dice.passes: Modify the dice test case to compute the union of the trace counts for the passed versions of this test case to use mtc_union to create dice.passes, instead of having dice.passes statically contain the list of the names of the passed trace count files (since that capability is deleted by this diff). tools/bootcheck: tests/Mmake.common: Fix the code for rerunning failed tests only. mdbcomp/prim_data.m: Eliminate some ambiguities in predicate names. compiler/*.m: Conform to the change to prim_data.m. compiler/error_util.m: Add reading files as a phase in error messages. compiler/mercury_compile.m: Use the new facilities in error_util for printing an error message. |
||
|
|
9eed887d33 |
This diff is the second step in implementing trace events.
Estimated hours taken: 24 Branches: main This diff is the second step in implementing trace events. It modifies label layouts to include room for solver-event-specific information, and modifies the compiler to generate this information. Modifications to the debugger to use this information, user-level documentation and test cases will come later. runtime/mercury_stack_layout.h: Modify label layouts to allow them to hold information about solver events. Modify the macros creating label layouts to include a null pointer as the value of the label layout's solver event field. For each such macro, add a version that puts a pointer to the label's solver event structure in that field. Modify the definition of the MR_Long_Lval type to allow the representation of constants, since without this capability solver events would often need to be preceded by code to put constant values (e.g. solver ids) into lvals. To make it easier to locate all the places where MR_Long_Lvals are used (which need to be updated), change the type MR_Long_Lval from a synonym for an int to a structure containing an int. runtime/mercury_types.h: Add the typedefs now required for mercury_stack_layout.h. runtime/mercury_goto.h: Add a macro needed by mercury_stack_layout.h. runtime/mercury_grade.h: Change the binary compatibility version number for debug grades, due to the change to label layouts. runtime/mercury_layout_util.c: Update the functions interpreting MR_Long_Lvals to conform to the change in mercury_stack_layout.h. runtime/mercury_deep_profiling_hand.h: Fix a bug, possibly the bug preventing us from bootchecking in deep profiling grades: stack slot numbers of ProcStatic structures are supposed to be plain integers, not MR_Long_Lvals. runtime/mercury_stack_trace.c: library/exception.m: trace/mercury_trace.c: Conform the change in MR_Long_Lval. runtime/mercury_trace_base.[ch]: Add a new port: the solver event port. Add a macro and a function for solver events: MR_SOLVER_EVENT and MR_solver_trace. For now, they do the same thing as MR_EVENT and MR_trace, but in future, they can do something else (e.g. generate information for a visualization tool). mdbcomp/prim_data.m: Add a new port: the solver event port. Rename all ports to eliminate clashes with language keywords such as "call". mdbcmp/trace_counts.m: browser/declarative_execution.m: slice/mcov.m: compiler/tupling.m: Conform to the change in port names, and to the addition of the new port. compiler/trace_params.m: Conform to the change in port names, and to the addition of the new port. Rename some function symbols to avoid some ambiguities. trace/mercury_trace_declarative.c: Ignore the solver port when building the annotated trace, since it doesn't fit into it. compiler/prog_event.m: Extend the representation of events to include names for the event attributes. compiler/call_gen.m: Implement event goals. The implementation consists of a call to MR_SOLVER_EVENT with a layout structure whose solver event field points to a solver event structure giving the event goal's arguments. Rename some function symbols to avoid some ambiguities. compiler/trace_gen.m: Add a predicate for generating solver events. Conform to the change in port names. Rename some function symbols to avoid some ambiguities. compiler/code_info.m: When recording trace layout information for a label, take an extra argument describing the label layout's associated solver event, if any. compiler/continuation_info.m: Extend the first representation of label layouts to include room for solver events. compiler/stack_layout.m: Convert the representation of solver events in continuation_info.m's data structure to the data structure required by layout_out.m. Conform to the changes in MR_Long_Lvals. compiler/layout.m: Extend the compiler's internal representation of the contents of label layout structures to accommodate the optional solver event field. compiler/layout_out.m: Generate the extended label layout structures, using the new macros in mercury_stack_layout.h if necessary. Conform to the change in the MR_Long_Lval type. Conform to the change in port names. Rename some function symbols to avoid some ambiguities. compiler/global_data.m: Modify rval_type_as_arg to require only the value of the relevant option, not a package of such options. This is for the new code in stack_layout.m. compiler/var_locn.m: Conform to the change in global_data.m. compiler/llds_out.m: Conform to the change in continuation_info.m. Delete this module's unused definition of rval_type_as_arg. compiler/opt_debug.m: Conform to the change in continuation_info.m. |
||
|
|
8396edc4b2 |
Let benchmark.report_stats/0 report real times on POSIX platforms.
Estimated hours taken: 1 Branches: main Let benchmark.report_stats/0 report real times on POSIX platforms. configure.in: Check for time.h and gettimeofday(). runtime/mercury_conf.h.in: Add MR_HAVE_TIME_H, MR_HAVE_GETTIMEOFDAY. Unrelated change: add MR_HAVE_PTHREAD_H. runtime/mercury_timing.c: runtime/mercury_timing.h: Add `MR_get_real_milliseconds'. runtime/mercury_wrapper.c: runtime/mercury_wrapper.h: Rename MR_time_* globals to MR_user_time_*. Add and initialise MR_real_time_* globals. library/benchmarking.m: Output real times in ML_report_stats(). Correct spelling of milliseconds. java/runtime/Native.c: java/runtime/Native.java.in: trace/mercury_trace_declarative.c: Correct spelling of milliseconds. |
||
|
|
2ece43e394 |
Add a new mdb command, 'shell', that allows users to execute shell commands
Estimated hours taken: 5 Branches: main Add a new mdb command, 'shell', that allows users to execute shell commands from within the debugger. Allow the user to give up to nine additional arguments to the 'source' command. Occurrences of the strings "$1" through "$9" in the sourced file are replaced by the corresponding additional arguments, allowing for parameterised scripts. Use the two new features mentioned above to add two more mdb commands: one to open a term, goal or exception in an external editor another command to perform a grep on a term, goal or exception (useful for seeing if a value occurs in a big map, for example). NEWS Mention the new commands. doc/mdb_categories: doc/user_guide.texi: Document the new commands. scripts/Mmakefile: scripts/mdb_open: scripts/mdb_vim: Add scripts for the new commands. scripts/mdbrc.in: Add aliases for the new shell, emacs, grep and vim commands. tests/debugger/completion.exp: tests/debugger/mdb_command_test.inp: Adjust for new commands. tests/debugger/save.exp: tests/debugger/save.exp2: Adjust for new commands. Replace system dependent strings with ZZZ instead of XXX. tests/debugger/Mmakefile: tests/debugger/shell.exp: tests/debugger/shell.inp: tests/debugger/shell.m: tests/debugger/shell_test_script: Test the shell and source commands. trace/mercury_trace_cmd_misc.c: Check if there are extra arguments to the source mdb command and pass them to MR_trace_source if there are. trace/mercury_trace_cmd_misc.h: Add shell command handling function prototype. trace/mercury_trace_declarative.c: Call MR_trace_call_system_display_error_on_failure instead of system when displaying benchmarking statistics for the declarative debugger. trace/mercury_trace_internal.c: trace/mercury_trace_internal.h: Implement the shell command and extend the source command to handle the optional extra arguments. trace/mercury_trace_readline.c: trace/mercury_trace_readline.h: Add a new function to read a line and replace all the occurrences of "$[1-9]" with the corresponding value from an array. Delete comments in the .c file that are duplicated in the .h file. trace/mercury_trace_util.c: trace/mercury_trace_util.h: Implement MR_trace_call_system_display_error_on_failure that executes a system call and displays an error message if the system call terminates abnormally. |
||
|
|
d11724a709 |
Fix a bug where subterm dependency tracking would break if a conditional
Estimated hours taken: 3 Branches: main Fix a bug where subterm dependency tracking would break if a conditional breakpoint was set. When the condition of a conditional breakpoint is evaluated, some Mercury code is called. Conditional breakpoints were being evaluated outside of the "safe" part of the call graph where the call sequence number is saved and restored in case any traced Mercury code updates the call sequence number. This meant that the Mercury code used to evaluate conditional breakpoints was updating the call sequence number and confusing the declarative debugger. This type of error, where Mercury code is called and the original sequence number is not restored afterwards has occured numerous times in the past (for example it occured when Ralph introduced the list command), so I have changed the MR_TRACE_CALL_MERCURY macro to save and restore the event, sequence and depth numbers to prevent this kind of error in the future. Previously the event, sequence and depth numbers were saved in an MR_Event_Details structure at the start of MR_trace_event and restored at the end. The MR_Event_Details structure needed to be passed to all the command functions in case there was a retry (since then the event, sequence and depth numbers must not be restored to their original values, but to new values). This is now all unnecessary, since the event, sequence and depth numbers will be restored after any Mercury code is called (as long as it is wrapped in MR_TRACE_CALL_MERCURY). runtime/mercury_trace_base.h: Save and restore the event, call sequence and depth numbers when calling Mercury code. trace/mercury_trace.c: trace/mercury_trace.h: trace/mercury_trace_declarative.c: trace/mercury_trace_declarative.h: trace/mercury_trace_external.c: trace/mercury_trace_internal.c: trace/mercury_trace_util.c: trace/mercury_trace_util.h: Do not pass around event_details anymore. And remove, now redundant, saving and restoring of the event details before and after calling Mercury code. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/condition_bug.inp: tests/debugger/declarative/condition_bug.m: Test that tracking of subterms works with conditional breakpoints. |
||
|
|
294294264e |
Speed up the declarative debugger by factoring out the code responsible for
Estimated hours taken: 7 Branches: main Speed up the declarative debugger by factoring out the code responsible for building the histogram in implicit subtrees into a seperate function. Call this new function directly from MR_trace when inside an implicit subtree. Because this function doesn't have to do very much and will be called for most events when the search space is large, this is a big speed improvement. A session which finds a bug in a leaf node of a run of the Mercury compiler on a small program using divide-and-query, takes 56% less time. trace/mercury_trace.c: trace/mercury_trace.h: Add MR_trace_real_decl_implicit_subtree. trace/mercury_trace_declarative.c: trace/mercury_trace_declarative.h: Export the global variables that keep track of the depth of events in the EDT and the histgram so they can be accessed by MR_trace_real_decl_implicit_subtree. Remove the MR_TRACE_EVENT_TOO_DEEP macro. This macro used to be more complicated, but now it's simple and obvious enough that we don't need a macro. In MR_trace_decl_debug avoid multiply dereferencing the same field in event_info, by dereferencing MR_trace_port and MR_trace_seqno once and then storing them in variables. Rename event_depth to node_depth, since this gives the depth of the corresponding EDT node. Replace MR_trace_calculate_event_depth with a macro MR_DD_CALC_NODE_DEPTH. We need it to be a macro to avoid function calls in MR_trace_real_decl_implicit_subtree. Call the MR_DD_CALC_NODE_DEPTH macro. If entering an implicit subtree set the callback function to MR_trace_real_decl_implicit_subtree. Move the check for suppressed events to MR_trace_include_event. Delete MR_trace_count_event_in_implicit_subtree since MR_trace_real_decl_implicit_subtree now does this job. Split the function which prints progress into two: one for printing progress when generating a subtree and one for printing progress when generating a supertree. Define two macros which call the above functions. One macro is called when inside and implicit subtree and one is called when constructing nodes. Print different messages when generating a subtree or a supertree. |
||
|
|
fefcf468a0 |
Use dicing information in the declarative debugger.
Estimated hours taken: 30 Branches: main Use dicing information in the declarative debugger. Each label in the program is assigned a suspicion based on a supplied dice. A new search mode then performs divide and query using the total suspicion of a subtree as the weighting of the subtree. browser/declarative_analyser.m: Parameterize the divide and query search mode by allowing it to work with an arbitrary weighting heuristic. Support two weighting heuristics: number of events and suspicion. Since there is still only one weight field for each suspect, if the weighting heuristic changes, then update all the weights of all the suspects. Return a different reason for asking a divide and query question, depending on the weighting heuristic. Some information (specifically how many suspect events remain and the estimated number of questions remaining for divide and query) returned by the info command depends on the current weighting heuristic being the number of events. If the current weighting heuristic is not the number of events then do not show this information. browser/declarative_debugger.m: Pass the trace node store to set_fallback_search_mode so that the weights can be recalculated if the search strategy changes. browser/declarative_edt.m: In the mercury_edt typeclass, rename the edt_weight method to edt_number_of_events and add a new method edt_subtree_suspicion. The weight field of each suspect in the search space can either be based on suspicion or number of events. Add a field to the search_space type to determine which weighting heuristic to use. Export predicates to get and set the current weighting heuristic being used. If the weighting heuristic changes the recalculate the weights of all the suspects. When calculating the weight of a suspect use the current weighting heuristic. browser/declarative_execution.m: Record a suspicion accumulator at each interface event which can be used to calculate the suspicion of a subtree in the EDT. Move the label_layout and proc_layout types as well as all utility predicates for those types to a new module, mdbcomp.label_layout. browser/declarative_oracle.m: browser/declarative_user.m: browser/debugger_interface.m: Import mdbcomp.label_layout. browser/declarative_tree.m: Adjust for the extra field in interface nodes in the annotated trace. Look at the weighting heuristic when calculating the weight of a subtree. browser/util.m: mdbcomp/program_representation.m: Move goal_path_string to mdbcomp.program_representation since it is needed in mdbcomp.label_layout. doc/user_guide.texi: Document the new search mode. mdbcomp/label_layout.m: This module contains the types label_layout and proc_layout and supporting predicates which were in mdb.declarative_execution. These types are needed in the mdbcomp.slice_and_dice module. mdbcomp/mdbcomp.m: Include label_layout. mdbcomp/slice_and_dice.m: Add functions for calculating different suspicion formulas. The intention is to experiment with different formulas in the future. Export predicates for reading a dice from the C backend. Export a predicate for retrieving the suspicion of a label given a dice. This predicate uses the suspicion_ratio_binary formula, since that seems most effective in my (as yet very limited) experience. I will implement better ways to control and customise the formula used in the future. mdbcomp/trace_counts.m: Add a function for constructing a path_port given a goal path and a trace port. If there is an unexpected exception when reading a trace counts file then print the unexpected exception. Add a predicate to convert trace count file types to a string and vica versa. runtime/mercury_stack_layout.h: Fix a typo. runtime/mercury_trace_base.c: runtime/mercury_trace_base.h: Export a function to look up the trace count slot for a label. Use this function when recording trace counts. This function will also be used in the declarative debugger backend to look up suspicions for labels. Add a function to initialise the array which records which ports need a goal path to uniquely identifiy the label. Initially I used this array elsewhere which is why I exported it. I didn't actually end up needing to use it in the final version, but I'm still exporting it, since it might be useful in the future. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/dice.exp: tests/debugger/declarative/dice.inp: tests/debugger/declarative/dice.m: Test the new search mode. tests/debugger/declarative/info.exp: tests/debugger/declarative/change_search.exp: The weigting heuristic is now printed with the info command. Also some information, such as the number of suspect events, is no longer printed if the weigthing heuristic is not the number of events (since then that information is not available). trace/mercury_trace_declarative.c: Add a function to setup the trace counts array with a suspicion for each label. For efficiency the suspicion is converted from a float to an integer between 0 and 100. If a flag is set, then increment an accumulator with the suspicion of each label executed as the annotated trace is being constructed. Store the value of the accumulator at interface events, so that the frontend can efficiently calculate the suspicion of any subtree. Remove a redundant variable and comment: the goal path is no longer passed to the frontend, because the frontend has access to the label_layout from which it can get the goal path (the variable and comment are artifacts of a previous change). When checking if a search mode is valid also check if failing and passing trace counts are required for the search mode. Allow abbreviations for the search mode arguments. trace/mercury_trace_declarative.h: Export the predicate to set up the suspicions for each label. trace/mercury_trace_internal.c: Allow passing and failing test case(s) to be passed as arguments to the dd command. If passing and failing test case(s) are supplied then record suspicions in the annotated trace even if the sdq search mode is not specified. The user could switch to the sdq search mode later on. Initialise some values which were causing warnings from the C compiler. browser/debugger_interface.m: browser/declarative_analyser.m: browser/declarative_debugger.m: browser/declarative_edt.m: browser/declarative_execution.m: browser/declarative_oracle.m: browser/declarative_tree.m: browser/declarative_user.m: browser/util.m: doc/user_guide.texi: mdbcomp/mdbcomp.m: mdbcomp/program_representation.m: mdbcomp/rtti_access.m: mdbcomp/slice_and_dice.m: mdbcomp/trace_counts.m: runtime/mercury_stack_layout.h: runtime/mercury_trace_base.c: runtime/mercury_trace_base.h: tests/debugger/declarative/Mmakefile: tests/debugger/declarative/dice.exp: tests/debugger/declarative/dice.inp: tests/debugger/declarative/dice.m: tests/debugger/declarative/info.exp: trace/mercury_trace_declarative.c: trace/mercury_trace_declarative.h: trace/mercury_trace_internal.c: |
||
|
|
372c882021 |
Fix some bad function prototypes.
Estimated hours taken: 0.1 Branches: main trace/mercury_trace_declarative.c: Fix some bad function prototypes. |
||
|
|
990e496007 |
Reduce the overhead of gathering the annotated trace by specializing the code
Estimated hours taken: 4 Branches: main Reduce the overhead of gathering the annotated trace by specializing the code paths that lead there. trace/mercury_trace.[ch]: Provide a new function MR_trace_real_decl, which combines the functionality of MR_trace_real and MR_trace_event and then discards several tests not needed when building the annotated trace. These tests include checking what the current mdb command is and whether a spypoint applies to the current event. Export MR_trace_ctrl for use by mercury_trace_declarative.c. This allows us to avoid the overhead of passing it around on every event, even though it is needed only for the final event. trace/mercury_trace_internal.[ch]: Delete the old type MR_Trace_Mode and the global variable MR_trace_decl_mode, which used to indicate whether we are gathering the annotated trace or doing something else. This binary choice is now encoded in whether MR_selected_trace_func_ptr points to MR_trace_real_decl or to MR_trace_real. Factor out some duplicate code. trace/mercury_trace_declarative.[ch]: Replace the old type MR_Trace_Mode with MR_Decl_Mode, which now says whether we are dumping the gathered annotated trace. Use the new method of switching from annotated trace gathering to other event processing and vice versa. |
||
|
|
468b4d4945 |
Include a script to test the performance of the debugger in the tools
Estimated hours taken: 4 Branches: main Include a script to test the performance of the debugger in the tools directory. Add a --test dd command option. The --test option causes the declarative debugger to simulate a session where the user answers `no' to all questions until a bug is found. Remove the dd_dd mdb command and add a --debug option to the dd command which does the same thing. The double maintenance of the dd_dd and dd commands was becoming onerous. browser/declarative_debugger.m: Export a predicate to set the testing flag in the user state. browser/declarative_oracle.m: Add a predicate to set the testing flag of the user state. browser/declarative_user.m: Add a new flag to the user state which indicates whether user answers should be simulated. If the new flag is set then simulate answers instead of asking the user. doc/user_guide.texi: Document the --test and --debug developer options. tools/dd_speedtest: Script for testing the performance of the declarative debugger. tools/extract_dd_stats.awk: Script for summarizing the output of dd_speedtest. trace/mercury_trace_declarative.c: Add a predicate to set the testing flag of the diagnoser. Rename the global variable which says whether the declarative debugger is being debugged. Use the -p ps option to print the Memory consumption of the current process instead of using grep. trace/mercury_trace_declarative.h: Fix a typo. Export the predicate to set the testing flag. Rename the global variable which says whether the declarative debugger is being debugged. trace/mercury_trace_internal.c: Add the --test and --debug options and remove the dd_dd command. |
||
|
|
db00e2afa6 |
Provide a mechanism to shut up progress messages from the declarative debugger
Estimated hours taken: 1 Branches: main Provide a mechanism to shut up progress messages from the declarative debugger for use in bootchecks, to remove a potential source of spurious test case failures. runtime/mercury_wrapper.[ch]: Add a new global, MR_mdb_decl_print_progress, that controls whether we print progress messages. Disable it if the new option --mdb-disable-progress is given. tools/bootcheck: Set the new option. trace/mercury_trace_declarative.c: Obey MR_mdb_decl_print_progress. Fix a bunch of departures from our coding standards. |
||
|
|
a9594132f2 |
Do not build an IO action map to pass around to predicates in the
Estimated hours taken: 4 Branches: main Do not build an IO action map to pass around to predicates in the declarative debugger that need access to IO actions. Instead look these up directly in the IO state. When using the declarative debugger to debug the Mercury compiler invoked on typecheck.m, which generates about 2.3 million IO actions, this change reduces the memory consumption by roughly half and reduces the delay between the end of execution trace generation and the asking of the first question from about 30 seconds to about 2 seconds. Use the --force-disable-tracing option to turn off tracing in the browser directory, even in .debug and .decldebug grades. configure.in Check that the --force-disable-tracing option is recongnised by the installed compiler, since we now use this option. browser/MDB_FLAGS.in: Turn off tracing for all code in the browser directory. browser/declarative_analyser.m: Remove the IO action map from the analyser state. Reformat a comment. browser/declarative_debugger.m: Do not initialise the IO action map, since it no longer exists. For final atoms, record a range of IO action numbers, instead a list of IO actions. The actions themselves can be looked up from the numbers when needed. browser/declarative_edt.m: browser/declarative_tree.m: Remove references to the IO action map. browser/declarative_user.m: Look up tabled IO actions directly in the IO state when they need to be displayed. Implement a predicate, find_tabled_io_action, which finds a particular tabled IO action given a range of IO action numbers and the sought tabled IO action number. Change several predicates to use the above instead of looking for the IO actions in a list. Implement a predicate, count_tabled_io_actions, which counts how many tabled and untabled IO actions are in a range of IO action numbers. Modify some predicates to use above. browser/io_action.m: Remove the io_action_map type and predicates used to construct values of this type. Add a new predicate, get_maybe_io_action, which looks up a possibly untabled IO action number and returns the IO action if it was tabled. The type returned by this predicate is maybe_tabled_io_action, which has two functors: tabled/1 and untabled/1. The argument of the untabled/1 functor is pointless, since it's just the IO action number, which is required to look up the return value of get_maybe_io_action in the first place. Remove the pointless argument. Add a new type, io_action_range, for recording a range of IO actions. Add an explicit `may_call_mercury' assertion to the pickup_io_action foreign proc. trace/mercury_trace_declarative.c: Do not keep track of the start and finish IO action numbers for the generated portions of the EDT and do not pass these to the frontend. We still record the current IO action number at each CALL and EXIT event. Fix a bug in the progress indicator which is exposed when event numbers become very big. |
||
|
|
b815ef062e |
Print the resident set size after garbage collection when printing the
Estimated hours taken: 0.1 Branches: main trace/mercury_trace_declarative.c: Print the resident set size after garbage collection when printing the EDT generation stats for the declarative debugger. Also print the time before garbage collection (the time after GC is already printed). Reformat the output slightly. |
||
|
|
3568775557 |
Fix a bug when printing out the EDT generation stats in the declarative
Estimated hours taken: 0.1 Branches: main trace/mercury_trace_declarative.c: Fix a bug when printing out the EDT generation stats in the declarative debugger. This error only shows up if the MR_DD_PRINT_EDT_STATS macro is defined. |
||
|
|
8ac929888b |
In the declarative debugger, dynamically calculate the depth implicit subtrees
Estimated hours taken: 15
Branches: main
In the declarative debugger, dynamically calculate the depth implicit subtrees
need to be built to, to achieve a desired weight.
This is done by recording the number of events at each depth in each
implicit subtree. The array used to record these depths need only be
as big as the desired weight divided by two, since the thinnest a tree can be
is a stick with two events at each depth (a CALL and an EXIT/FAIL/EXCP).
Initially the tree is built down to a predetermined, conservative depth. At
the root of each implicit subtree in the newly materialized tree, we record
the depth the implicit subtree needs to be built to, to achieve the desired
weight (this is refered to as the ideal depth in the code). This is done
everytime we materialize a new implicit subtree.
This results in about a 3.6% slowdown when the declarative debugger reexecutes
a portion of the program. However, this also reduces the number of
reexecutions of the program, since we needn't be conservative about how deep to
build subtrees to anymore. We also avoid adding too many nodes to the
annotated trace if the tree has a large branching factor, so we are able to
control memory usage more easily.
I also added a progress indicator which is activated if a reexecution continues
for more than a second.
I added some macros to optionally print benchmarking information when
building a new portion of the annotated trace.
browser/declarative_debugger.m:
Pass the ideal depth of a subtree to the backend.
browser/declarative_edt.m:
Handle the case where edt_dependency says an explicit subtree is
required.
browser/declarative_execution.m:
Record the ideal depth at the CALL event corresponding to the root
of an implicit subtree.
Add predicates to get and set this value from the backend.
browser/declarative_tree.m:
Export a new predicate, trace_implicit_tree_info, which is used to
get the info stored at the root of an implicit root.
Make trace_dependency respond that an explicit subtree is required
if it needs to explore the children of an implicit subtree. Previously
we made this situation impossible by requiring the backend to
always generate the children of nodes at the depth limit. This,
however, complicated the backend code unnecessarily.
doc/user_guide.texi:
Change the --depth-step-size dd option to just --depth which is now
only used as the initial depth to build the subtree to. Comment out
the --depth option, since it requires knowledge of the internal
workings of the declarative debugger.
Document the new dd option, --nodes, which controls how many nodes
to build in the annotated trace at a time.
library/gc.m:
Export garbage_collect so it can be called from the backend when
printing out benchmarking information.
tests/debugger/declarative/*.{inp*, exp*}
For the tests set the --nodes and --depth options to a low value, so
that we exercise the code that builds new portions of the annotated
trace.
trace/mercury_trace_declarative.[ch]:
Move the MR_DECL_UNTABLED_IO_RETRY_MESSAGE macro to
mercury_trace_declarative.h.
Add some macros and functions which print benchmarking information
if the MR_DD_PRINT_EDT_STATS macro is defined.
Add an overview of the backend.
Show progress if the tree takes more than a second to generate.
Count the events at each depth in each implicit subtree.
Calculate the ideal depth when exiting an implicit subtree and store
this in the annotated trace.
Add the depth limit as an argument to MR_trace_restart_decl_debug
instead of using the value of the global MR_edt_depth_step_size
(which no longer exists).
Do not materialize the children of nodes at the depth limit, since
this is no longer necessary.
trace/mercury_trace_internal.c:
Add and handle the --nodes dd option. Rename the --depth-step-size
option to --depth.
|
||
|
|
68587c5324 |
Look up atoms in the knowledge base as soon as they are added to the search
Estimated hours taken: 3 Branches: main Look up atoms in the knowledge base as soon as they are added to the search space. This generalises a feature of the debugger which I earlier removed for simplicity, where the analyser would pass a list of questions to the oracle. If the oracle had any of the questions in its knowledge base it would return those answers to the analyser, otherwise it would ask the user. This was changed so that only one question was asked of the oracle at a time. Now the analyser still asks only one question of the oracle at a time (through an analyser response), but the oracle's knowledge base is consulted every time a new suspect is added to the search space i.e. as it is being searched. The main benefit of this is that search algorithms can immediately avoid generating queries about trusted nodes. This fixes some slightly annoying behaviour with subterm dependency tracking. Previously if a subterm was bound by a trusted predicate, then this would cause a binary search to be performed between the trusted predicate and the root of the search space. It would be better for the dependency tracking algorithm to first ask about the closest untrusted call to the call that bound the subterm, since often subterms are bound by internal library predicates. The subterm dependency algorithm was unable to do this, however, because it didn't know which calls were trusted while it was tracking the subterm. Now it does. browser/declarative_analyser.m: Pass the oracle state and the io action map to any predicates that add suspects to the search space, so that the oracle's knowledge base can be consulted. Move the code that checks if a bug has been found from decide_analyser_response to the top-down search routine. This is okay since all the other search algorithms will eventually call top-down search if they can't find any unknown suspects to ask questions about. When keeping track of the last unknown suspect, double check that the suspect is still unknown before asking a question about it, since its status may have been changed because, for example, an erroneous child was added to the search space. Pass the mode of the subterm to give_up_subterm_tracking/3, since tracking of the subterm should only be stopped if it's the input to an erroneous node. browser/declarative_debugger.m: Add a subtype of decl_answer/1 that specifies those answers which can be obtained from places other than the user. Pass the oracle state to the analyser. browser/declarative_edt.m: Make first_unknown_descendent return a new type which captures whether an unknown suspect was found, an unknown suspect was not found, or an explicit_subtree was requested. Previously this predicate would fail if an explicit subtree was required, which meant that any suspects added to the search space during the call to first_unknown_descendent would have to be added again once the subtree had been generated. This also removes the need for pick_implicit_root. Pass the oracle state and the io action map to any predicates that add suspects to the search space, so that the oracle's knowledge base can be consulted. Remove the suspect_is_bug predicate, since this is now done by top-down search in the anaylser. Export non_ignored_descendents and suspect_inadmissible so the analyser can use it. Return the mode of a subterm in its origin. Make give_up_subterm_tracking consider the mode of the subterm. Check if the oracle knows the answer to a question when adding children to the search space, or adding a new suspect at the top of the search space. Also give better names to some variables in these predicates. browser/declarative_oracle.m: Export answer_known/3 so that declarative_edt can call it. tests/debugger/declarative/binary_search.exp: tests/debugger/declarative/binary_search.exp2: tests/debugger/declarative/binary_search.inp: tests/debugger/declarative/binary_search.inp2: tests/debugger/declarative/family.exp: tests/debugger/declarative/family.inp: These test cases now ask fewer questions, except for one dd session in the binary_search test case. This, however, is a fix for the quirk mentioned above where a binary search would be started if the binding node is trusted. The new behaviour is more predictable and preferable even if an extra question is asked. trace/mercury_trace_declarative.c: Fix a bug where the dd_dd command didn't work. This was introduced by an earlier diff in which I cleaned up mercury_trace_declarative.c. |
||
|
|
7ab6043c76 |
When resuming a declarative debugging session set the search mode only
Estimated hours taken: 1 Branches: main When resuming a declarative debugging session set the search mode only if it is explicitly given as an option. doc/user_guide.texi Document when exactly a search mode is used. tests/debugger/declarative/resume.exp: tests/debugger/declarative/resume.inp: Test the above. trace/mercury_trace_declarative.c: Wrap calls to mercury code in MR_TRACE_CALL_MERCURY. trace/mercury_trace_internal.c: Set the search_mode of the analyser if it is a new session or the search mode is explicitly given. |
||
|
|
cabb22d14f |
Improve the declarative debugger interface.
Estimated hours taken: 7 Branches: main Improve the declarative debugger interface. The two main changes are to use the mdb help system and not re-display the question after the user issues a command which does not answer the question. For example if the user issues an `info' command, then previously the question would be redisplayed after the requested information and if the question is big then the information would be scrolled off the screen. browser/declarative_analyser.m: Remove extra new line characters when printing info. These are no longer necessary since the question is not redisplayed. browser/declarative_debugger.m: Pass the help system from mdb to the oracle state when initialising the diagnoser. browser/declarative_oracle.m: Pass the help system to the user state when initialising the oracle state. browser/declarative_user.m: Add two new fields to the user state: one to keep a reference to the help system and one to indicate whether the current question should be displayed when getting a user input. Allow the user to redisplay the question by issuing a `print' command with no arguments. If the question is not to be displayed the show a "dd>" prompt. Change the `abort' command to `quit'. This is more consistent with the rest of mdb. doc/commands: Add a script to print all the commands in a section in the user guide. doc/generate_mdb_doc: Generate help for the declarative debugger. doc/mdb_categories: Add a category, `decl', for commands that can be executed inside the declarative debugger. Change the `dd' category to mdb_dd, because 1) `help dd' used to show help about the `dd' category AND the `dd' command and 2) `dd' is too general a category name now that we have a `decl' category. Add an item, `decl_debug' to the concepts category. doc/user_guide.texi: Document some dd commands which previously weren't documented here. Add a short overview of the declarative debugger. This is displayed when the user issues a `help' command from within the dd. Move the bit about the behaviour when no command is given to before the list of commands. This is necessary so util/info_to_mdb.c doesn't include this in the help of the last command in the list. tests/debugger/declarative/app.exp: tests/debugger/declarative/app.inp: tests/debugger/declarative/browse_arg.exp: tests/debugger/declarative/browse_arg.inp: tests/debugger/declarative/browser_mode.exp: tests/debugger/declarative/browser_mode.inp: tests/debugger/declarative/confirm_abort.exp: tests/debugger/declarative/confirm_abort.inp: tests/debugger/declarative/dependency.exp: tests/debugger/declarative/dependency.inp: tests/debugger/declarative/find_origin.exp: tests/debugger/declarative/find_origin.exp2: tests/debugger/declarative/info.exp: tests/debugger/declarative/info.inp: tests/debugger/declarative/io_stream_test.exp: tests/debugger/declarative/io_stream_test.exp2: tests/debugger/declarative/mapinit.exp: tests/debugger/declarative/mapinit.inp: tests/debugger/declarative/output_term_dep.exp: tests/debugger/declarative/output_term_dep.inp: tests/debugger/declarative/resume.exp: tests/debugger/declarative/resume.inp: tests/debugger/declarative/skip.exp: tests/debugger/declarative/skip.inp: tests/debugger/declarative/solutions.exp3: tests/debugger/declarative/tabled_read_decl.exp: Update tests. trace/mercury_trace_declarative.c: trace/mercury_trace_help.c: trace/mercury_trace_help.h: Pass the help system to the frontend. |
||
|
|
a6febdd520 |
Clean up trace/mercury_trace_declarative.c by breaking MR_trace_decl_debug into
Estimated hours taken: 5 Branches: main Clean up trace/mercury_trace_declarative.c by breaking MR_trace_decl_debug into several functions. This function was getting very big and difficult to maintain. trace/mercury_trace_declarative.c: Decompose MR_trace_decl_debug into smaller functions: MR_trace_edt_build_sanity_check, which checks that we haven't passed the last event for the portion of the trace being constructed; MR_trace_include_event, which decides if an event should be included in the annotated trace and resets the depth if the event is at the top of an area to be materialized; MR_trace_calculate_event_depth, which calculates the depth in the EDT of the current event and sets the global MR_edt_depth appropriately; And MR_trace_construct_node, which constructs a node in the annotated trace. |
||
|
|
c4cc27386e |
Fix three bugs in the declarative debuggger.
Estimated hours taken: 15
Branches: main
Fix three bugs in the declarative debuggger.
The first two are to do with IO tabling in the declarative debugger:
The first bug was exposed when a new explicit supertree was built over a part
of the program that did IO. The starting IO action sequence number was not
being set correctly, causing some IO actions to be omitted from the resulting
IO action map. The fix is to set the starting IO action sequence number to
the IO action sequence number at the CALL event for the topmost node of the new
explicit supertree.
The second bug was exposed when a retry was done over a part of the program
whose IO was not tabled. This caused the building of the IO action map to
fail. Specifically the MR_trace_get_action C function would abort with a
message that the IO action number was out of range. The fix is to only record
tabled IO actions in the IO action map and then warn the user if a question is
asked where some of the IO actions for the atom haven't been tabled.
The third bug causes the declarative debugger to throw an exception when
an explicit subtree of depth 1 is requested. This was because MR_edt_depth
(the global which keeps track of the current depth of the EDT) was not being
set correctly.
browser/declarative_debugger.m:
Allow the IO actions for a final atom to be tabled or untabled.
browser/declarative_tree.m:
Extract a list of the tabled and untabled IO actions for a question
from the IO action map.
browser/declarative_user.m:
Bring module imports up to date with coding standards.
Only allow browsing and printing of tabled IO actions.
Print all the tabled IO actions for a question and print a warning if
there are any untabled IO actions for a question.
Use "tabled IO actions" instead of "io actions" when displaying how
many tabled IO actions there are for a question.
browser/io_action.m:
Add a type to record if an IO action is tabled or not.
Bring module imports up to date with coding standards.
Only record tabled IO actions in the IO action map used by the
declarative debugger.
runtime/mercury_trace_base.[ch]:
Make MR_trace_get_action return true or false depending on whether
the requested IO action was tabled or not, so that we can easily
detect this in io_action.m above.
tests/debugger/declarative/io_stream_test.exp2:
Update expected output.
tests/debugger/declarative/tabled_read_decl.{exp,inp,m}:
Add regression tests for all three bugs.
trace/mercury_trace.[ch]:
Allow the message printed by the retry command, when it is about to
retry over untabled IO, to be customised. This allows the declarative
debugger to print a different message when it needs to do a retry
over untabled IO. Previously the message seemed unrelated to the
declarative debugging session.
Get MR_trace_retry to report if it did an unsafe retry over
untabled IO.
trace/mercury_trace_declarative.c:
Print a friendlier message when attempting to retry over untabled IO.
Set the initial IO action sequence number to the IO action sequence
number at the time of the CALL event of the topmost node of the new
explicit supertree.
Initialise MR_edt_depth to -1, instead of 0, since it will be
subsequently made 0.
When building an explicit supertree, only ask the user once if a
retry can be done over untabled IO.
Because of this rename MR_trace_retry_max to MR_trace_retry_supertree,
since it should now only be used when building a supertree.
When checking if we are at the final event for the top of the new
explicit supertree, add the depth_check_adjustment. This ensures
that the final event has the same depth as the corresponding call
event.
Add an argument to MR_decl_diagnosis to tell it whether a new tree
was generated, or to resume a previous session. Previously the resume
option was implied by a null tree, which made the code less readable.
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
Pass the new extra arguments to MR_trace_retry.
trace/mercury_trace_readline.c:
If a readline prompt spans multiple lines then the display gets messed
up when the user starts typing (not sure if this is a bug in readline
or not). Fix this by only passing the last line of a prompt to
readline and just fprintf'ing any previous lines.
trace/mercury_trace_vars.c:
Handle the new MR_bool return value of MR_trace_get_action.
|
||
|
|
309910d736 |
Change the mechanism we use to transmit a representation of procedure bodies
Estimated hours taken: 16 Branches: main Change the mechanism we use to transmit a representation of procedure bodies from the compiler to the declarative debugger from Mercury terms to a bytecode. This achieves two objectives. First, the code for Mercury terms worked only as long as the compiler used the same data representation as the program being compiled; it generated incorrect term representations when e.g. the compiler generating code in reserve tag grades. Second, the new representation is significantly smaller. The total size of the .c files in the compiler directory in grade asm_fast.gc.decldebug.tr is now only 213 Mb compared with 313 Mb previously (a reduction of almost one third). The executable file size of a compiler compiled in asm_fast.gc.decldebug.tr is now only 59 Mb, compare with 64 Mb previously (a reduction of almost 8%, and there is room for further reductions). The overhead of the decldebug grade when compared with a plain debug grade now only about 25%, compared to about 36% before. The downside is that the procedure body representation must now be constructed by the declarative debugger from the bytecode instead of being available directly. We minimize this effect by using a cache to ensure that each procedure's body representation is constructed at most once. browser/declarative_execution.m: Do not include the procedure representation in call nodes. This should make the annotated trace somewhat smaller and quicker to construct. Since this code will be executed many more times than the number of procedures whose bodies are needed by subterm dependency tracking, the overall effect of this change on speed should be positive. Instead, add code to construct procedure body representations on demand from bytecode, which is reachable indirectly through the call's node label label structure. browser/declarative_tree.m: Conform to the new structure of call nodes. compiler/prog_rep.m: Replace the code that generated the term representation of procedure bodies with code that generates a bytecode representation of procedure bodies. compiler/static_term.m: Delete this file, since it is no longer needed. compiler/notes/compiler_design.html: Document the deletion of static_term.m. mdbcomp/program_representation.m: Add the definitions related to the structure of the bytecode that are shared by the compiler and the declarative debugger. This includes the representations of determinisms. compiler/code_model.m: To prevent requiring double maintenance, use the facilities now in mdbcomp/program_representation.m to encode determinisms. runtime/mercury_stack_layout.h: compiler/layout.m: compiler/layout_out.m: compiler/opt_debug.m: compiler/stack_layout.m: Replace the proc layout field holding the procedure representation term with the field holding the procedure representation bytecode. runtime/mercury_grade.h: Record the breaking of backward compatibility in debug grades. compiler/options.m: Add an option for use by compiler implementors while implementing changes like this. runtime/mercury_trace_base.[ch]: Add the hash table that caches the results of bytecode translations. trace/mercury_trace_declarative.c: Do not include procedure representations when constructing call nodes, since it is no longer necessary. trace/mercury_trace_internal.c: Update the code that deals with procedure bodies to use the bytecode representation. |
||
|
|
1a708a0ccc |
Add a new declarative debugger response, `info', which shows some information
Estimated hours taken: 6 Branches: main Add a new declarative debugger response, `info', which shows some information about the current question and the state of the bug search. browser/declarative_analyser.m Add the show_info predicate. browser/declarative_debugger.m Handle the oracle show_info response. browser/declarative_edt.m Add a new method to the mercury_edt typeclass, edt_context, which returns the filename and line number of the predicate for a node. browser/declarative_execution.m Instead of recording the goal path of a call in its parent, record the return label. The goal path and the parent context can then be derived from the return label. Add a function to get the goal path from a return label. Add a function to get the context of a label. Modify the exported predicates used to build the annotated trace to take a return label instead of the goal path. browser/declarative_oracle.m Add a `show_info' oracle response. browser/declarative_tree.m Implement trace_context which returns the filename and line number of the predicate that corresponds with a node in the annotated trace. Derive a call's goal path in its caller from the return label where necessary. browser/declarative_user.m Add and document the user response `info'. browser/dice.m Fix a line that was over 79 characters. doc/user_guide.texi Document the info command. Say that the --resume option can be used to resume an aborted or pd'd session. tests/debugger/declarative/Mmakefile tests/debugger/declarative/info.exp tests/debugger/declarative/info.inp tests/debugger/declarative/info.m Test the new response. trace/mercury_trace_declarative.c Pass the return label when constructing the annotated trace. |
||
|
|
436c5e6a6f |
Add --resume option to `dd' command. This resumes the previous declarative
Estimated hours taken: 25 Branches: main Add --resume option to `dd' command. This resumes the previous declarative debugging session and allows the user to switch between the procedural and declarative debuggers freely. browser/declarative_analyser.m Add analysis_type type which is used to tell the analyser whether it must start a new session or resume a previous session. browser/declarative_debugger.m Add two versions of the exported diagnosis predicate: one to resume a previous session and one to start a new session. browser/declarative_user.m Print usage message to the correct output stream. doc/user_guide.texi Document the new option. runtime/mercury_stack_trace.c runtime/mercury_stack_trace.h Add a function to find the first call on the stack whose event number is less than or equal to a given event number or whose call sequence number is less than or equal to a given call sequence number. Since this new function uses some code very similar to existing code in the function that prints the stack, separate this code into a new function called MR_call_details_are_valid. trace/mercury_trace_declarative.c trace/mercury_trace_declarative.h Previously it could be safely assumed that the current event would be somewhere inside the materialized portion of the annotated trace, so it was sufficient to record the topmost node of the annotated trace and retry to there whenever we needed to build a new subtree (and to the topmost node plus some extra for a supertree). Now, however, the user may go to any event in the program before resuming the previous dd session. We could just retry to the call event for main/2, but this would be far from optimal, especially if the user is debugging code deep down in the program's call tree. Instead we retry to the first call on the stack whose event number is less than or equal to the call event number of the node we want to build a subtree for and then start forward execution from there. When building a supertree we retry to the first call on the stack whose event number is less than or equal to the event number of the call at the top of the currently materialized portion of the annotated trace. Then when we get to the call at the top of the currently materialized portion of the annotated trace through forward execution, we do a retry to the desired depth and start building the new supertree. Desribe the function of some of the global variables in more detail. Remove the global MR_edt_topmost_call_depth since it is no longer needed. Fix an inconsistency where the depth limit was being set to MR_edt_depth_step_size when starting a dd session, but to MR_edt_depth_step_size + 1 when building an additional portion of the annotated trace. Don't update the saved event details from the global event number/seqno/depth variables at the start of MR_decl_diagnosis. The globals could have been updated by a previous call to Mercury code and could have incorrect values. tests/debugger/declarative/Mmakefile tests/debugger/declarative/resume.exp tests/debugger/declarative/resume.inp tests/debugger/declarative/resume.m Test the --resume option. Specifically test the creation of a supertree and subtree from a resumed session where the user has gone to an event before and after the materialized portion of the annotated trace. trace/mercury_trace_internal.c Handle the --resume option. |
||
|
|
3ee6e024fe |
Record label layouts in the annotated trace.
Estimated hours taken: 7 Branches: main Record label layouts in the annotated trace. This does away with the need to store goal path strings and proc_layouts in the annotated trace, since both can be obtained from the label layout (we still however need to store the goal path of a call in its parent for subterm dependency tracking). The label layouts will be used for displaying more detailed information in declarative debugging sessions (such as line numbers) and also for for slicing and dicing in the declarative debugger. browser/declarative_execution.m Add label_layout foreign types and some useful functions on this type. Add label_layout field to each event in an annotated trace. Record just the arguments of an atom for call and exit events in the annotated trace. The complete atom can be constructed from the label_layout and the arguments. When recording argument values add them to the front of the argument list instead of inserting them in a specified position in the argument list. This means the arguments must be added in reverse order in trace/mercury_trace_declarative.c. Adjust the predicates for building the annotated trace to also accept a label_layout. browser/declarative_debugger.m Get the proc_layout from the label_layout. browser/declarative_tree.m Make adjustments for the extra field. trace/mercury_trace_declarative.c Pass the label_layout when constructing pieces of the annotated trace. Construct only the atom's arguments. Also when adding the arguments add them in reverse order, because of the change in browser/declarative_execution mentioned above. |
||
|
|
387a6c8878 |
Allow uses to associate with each breakpoint in mdb a list of print actions
Estimated hours taken: 8
Branches: main
Allow uses to associate with each breakpoint in mdb a list of print actions
that should be executed automatically when execution arrives at the breakpoint.
A new print list (a list of things to be printed) can be attached to an
existing breakpoint via the new "break_print" command, or it can be attached
to a breakpoint being created via the existing "break" command.
NEWS:
Mention the new capability.
doc/user_guide.texi:
Document the new capability.
trace/mercury_trace_spy.[ch]:
Keep a print list with every breakpoint, and add functions to
manipulate print lists.
Convert this module to four space indentation to keep indent levels
manageable.
trace/mercury_trace.c:
Conform to the updated interface of the mercury_trace_spy module.
trace/mercury_trace_internal.[ch]:
When the internal debugger is invoked at an event, whether
interactively or not, take an extra parameter specifying the
print list, if any, to be executed.
Implement the new "break_print" command and the new options of
the "break" command.
Conform to the updated interface of the mercury_trace_spy module.
trace/mercury_trace_declarative.c:
Conform to the updated interface of the mercury_trace_internal module.
tests/debugger/breakpoints.{inp,exp*}:
Test the new capability.
tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
Update to reflect the new command.
|
||
|
|
e573b2d16e |
Disable higher order specialization for the mdb.declarative_edt module
Estimated hours taken: 12 Branches: main Disable higher order specialization for the mdb.declarative_edt module since mdb.declarative_edt.revise_root/3 exposes a bug in this optimization. Allow the declarative debugger to continue to be debugged after a new portion of the annotated trace has been generated. browser/Mercury.options Disable higher order specialization for the mdb.declarative_edt module. trace/mercury_trace_declarative.c trace/mercury_trace_declarative.h Add a global variable MR_trace_decl_in_dd_dd_mode to indicate when the declarative debugger was invoked with the dd_dd command. A seperated variable must be used to trace_mode, since trace_mode is changed to MR_TRACE_INTERACTIVE when the declarative debugger is started, so it's not possible to tell that it was invoked with the dd_dd command when diagnosis is restarted after a new portion of the annotated trace has been generated. trace/mercury_trace_internal.c Set MR_trace_decl_in_dd_dd_mode appropriately depending on whether `dd' or `dd_dd' was used to invoke the declarative debugger. When the dd_dd command is used, set the trace_mode to MR_TRACE_DECL_DEBUG instead of MR_TRACE_DECL_DEBUG_DEBUG since the value of MR_trace_decl_in_dd_dd_mode is now used instead to determine if the dd_dd command was given. trace/mercury_trace_internal.h Remove the MR_TRACE_DECL_DEBUG_DEBUG trace mode option since it is no longer used. |