mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
7dccb03be114fbbc0b6c514b7f7fc94696e42487
50 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
958ba814bc |
Show cliques in mdb stack traces less obtrusively.
like this:
mdb> stack
0 pred mutrec.q1/3-0 (det) (mutrec.m:133)
1 ┌ 2* pred mutrec.p2/3-0 (det) (mutrec.m:106 and others)
3 │ pred mutrec.p3/3-0 (det) (mutrec.m:122)
4 │ 2* pred mutrec.p2/3-0 (det) (mutrec.m:102 and others)
6 └ pred mutrec.p3/3-0 (det) (mutrec.m:122)
7 2* pred mutrec.p1/3-0 (det) (mutrec.m:82 and others)
9 pred mutrec.test/2-0 (det) (mutrec.m:42)
10 pred mutrec.main/2-0 (det) (mutrec.m:33)
This implements a suggestion by Peter Wang from *April 2012*.
runtime/mercury_stack_trace.h:
Add a new field to the data structure that represents each line
in a stack trace. This field represents the string, if any,
that implements the boxes around the calls in the clique.
This will be two characters, a box character and a space,
e.g. for the call at level 6, it will be "└ ".
runtime/mercury_stack_trace.c:
Use the new capability to add boxes to calls in cliques,
and equal-length padding to the calls that are not in cliques
but which share stack traces with calls that are.
Initialize some variables closer to their first use.
Group some related statements together. Add some comments.
Delete some already-acted-upon TODOs.
tests/debugger/mutrec.exp:
tests/debugger/mutrec_higher_order.exp:
Expect the updated clique markers.
NEWS.md:
doc/user_guide.texi:
Document the change.
|
||
|
|
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.
|
||
|
|
67326f16e4 |
Fix style issues in the runtime.
Move all .h and .c files to four-space indentation without tabs, if they weren't there already. Use the same vim line for all .h and .c files. Align all backslashes at the ends of lines in macro definitions. Align close comment signs. In some places, fix inconsistent indentation. Fix a bunch of comments. Add XXXs to a few of them. |
||
|
|
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). |
||
|
|
f6fafa150d |
Fix Mantis bug 314 for temp frames created by nondet procedures.
Also fix some bugs in related code, and improve the related debugging
infrastructure.
-------------------
runtime/mercury_stacks.[ch]:
Fix bug 314 for temp frames created by nondet procedures. The fix will
probably also work for *det* procedures that create temp frames on the
nondet stack, but I can't think of a way to test that, because det
procedures create such frames only in very specific circumstances,
and I cannot think of a way to nest a recursive call inside those
circumstances.
The problem was that when we were creating new temp frames on
the nondet stack, we did not check whether the current nondet stack segment
had room for them. We now do.
The stack trace tracing code needs to know the size of each nondet stack
frame, since it uses the size to classify frames as temp or ordinary.
The size is given by the difference in address between the address of the
frame and the address of the previous frame. This difference would yield
an incorrect size and hence an incorrect frame classification if a temp
frame were allowed to have a frame on a different segment as its
immediate predecessor.
We prevent this by putting an ordinary (i.e. non-temp) frame at the bottom
of every new nondet stack segment as a sentinel. We hand-build this frame,
since it is not an "ordinary" ordinary frame. It is not created by a call,
so it has no meaningful success continuation, and since it does not make
any calls, no other frame's success continuation can point to it either.
If backtracking reaches this sentinel frame, we use this fact to free
all the segments beyond the one the sentinel frame is in, but keep the
frame the sentinel frame is in, since we are likely to need it again.
Document the reason why MR_incr_sp_leaf() does not have to check
whether a new stack segment is needed. (See the fix to llds_out_instr.m
below.)
runtime/mercury_stack_trace.[ch]:
When traversing the nondet stack, treat the sentinel frame specially.
We have to, since it is an ordinary frame (i.e. it is not a temp frame),
but it is not an "ordinary" ordinary frame: it does not make calls,
and hence calls cannot return to it, and it does not return to any
other frame either. It therefore does not have the layout structures
(label and proc) that the nondet stack traversal expects to find.
Fix an old bug: the nondet stack traversal used a simple directional
pointer comparison to check whether it has reached the bottom of the nondet
stack. This is NOT guaranteed to work in the presence of stack segments:
depending on exactly what addresses new stack segments get, a stack frame
can have an address BELOW the address of the initial stack frame
even if it is logically ABOVE that stack frame.
Another old bug was that a difference between two pointers, which could
be 64 bit, was stored in an int, which could be 32 bit.
The nondet stack traversal code used a similar directional comparison
to implement optionally stopping at an arbitrary point on the nondet stack.
Fixing this facility (the limit_addr parameter of MR_dump_nondet_stack)
while preserving reasonable efficiency would not be trivial, but it would
also be pointless, since the facility is not actually used. This diff
deletes the parameter instead.
Move some loop invariant code out of its loop.
trace/mercury_trace_cmd_developer.c:
trace/mercury_trace_external.c:
Don't pass the now-deleted parameter to mercury_stack_trace.c.
runtime/mercury_wrapper.c:
Record the zone of the initial nondet stack frame, since the fix
of mercury_stack_trace.c needs that info, and it is much more efficient
to set it up just once.
tests/hard_coded/bug314.{m,exp}:
The regression test for this bug.
tests/hard_coded/Mercury.options:
Compile the new test case with the options it needs.
tests/hard_coded/Mmakefile:
Enable the new test case.
-------------------
runtime/mercury_wrapper.c:
The compiler knows the number of words in a stack frame it is creating,
not necessarily the number of bytes (though it could put bounds on that
from the number of tag bits). Since this size must sync with the runtime,
change the runtime's variable holding this size to also be in words.
Note that similar changes would also be beneficial for other sizes.
compiler/llds_out_instr.m:
Conform to the change in mercury_wrapper.c, fixing an old bug
(mercury_wrapper.c reserved 128 BYTES for leaf procedures, but
llds_out_instr.m was using that space for procedures whose frames
were up to 128 WORDS in size.)
compiler/mercury_memory.c:
Conform to the change in mercury_wrapper.c.
-------------------
runtime/mercury_memory_zones.h:
Instead of starting to use EVERY zone at a different offset, do this
only for the INITIAL zones in each memory area, since only on these
is it useful. When the program first starts up, it WILL be using
the initial parts of the det stack, nondet stack and heap, so it is
useful to make sure that these do not collide in the cache. However,
when we allocate e.g. the second zone in e.g. the nondet stack, we are
no more likely to be beating on the initial part of any segment
of the det stack than on any other part of such segments.
If a new debug macro, MR_DEBUG_STACK_SEGMENTS_SET_SIZE is set (to an int),
use only that many words in each segment. This allows the segment switchover
code to be exercised and debugged with smaller test cases.
runtime/mercury_conf_param.h:
Document the MR_DEBUG_STACK_SEGMENTS_SET_SIZE macro.
Convert this file to four-space indentation with tabs expanded.
-------------------
runtime/mercury_overflow.h:
Make abort messages from overflows and underflows more useful by including
more information.
runtime/mercury_overflow.c:
Add a new function to help with the better abort messages.
Since this file did not exist before, create it.
runtime/Mmakefile:
Add the new source file to the list of source files.
-------------------
runtime/mercury_debug.[ch]:
Fix problems with the formatting of the debugging output from existing
functions.
Add new functions for dumping info about memory zones.
Factor out some common code.
Convert the header file to four-space indentation.
-------------------
runtime/mercury_grade.c:
Generate an error if stack segments are specified together with stack
extension
-------------------
trace/.gitignore:
util/.gitignore:
tests/debugger/.gitignore:
List some more files.
-------------------
runtime/mercury_context.c:
runtime/mercury_engine.[ch]:
runtime/mercury_misc.h:
compiler/notes/failure.html:
Fix white space.
|
||
|
|
c733b0359b |
Give the Mercury debugger the ability to detect cliques of mutually recursive
Estimated hours taken: 30
Branches: main
Give the Mercury debugger the ability to detect cliques of mutually recursive
predicates on the stack. Exploit this ability to enhance the debugger's
level, retry, finish and stack commands.
runtime/mercury_stack_trace.[ch]:
Add a function, MR_find_clique_entry, that detects the clique
that contains the top stack frame. This is used to implement the new
arguments "clentry" and "clparent" (short for clique entry and parent)
options of the level, retry and finish commands. "clique" is a synonym
for "clentry" in these commands.
Add a function, MR_dump_stack_layout_clique, that implements the
new capabilities of the stack command. It can detect more than one
clique, anywhere on the stack.
To make this possible, modify the existing functions for printing
the lines of stack traces. These used to keep some information around
between calls in global variables. Now that information is stored in
two structures that the caller passes them. One contains the parameters
that govern what is to be printed, the other contains information about
what has been buffered up to be printed, but has not been flushed yet.
(The old code was confused in its handling of parameters. Some parts
of it looked up the global variables storing them, while other parts
were given the parameter values by their callers, values that could
have been -but weren't- inconsistent.)
Change the buffer flushing code to be idempotent, since in the new
code, sometimes it is hard to avoid flushing the buffer more than once,
and we want only the first to print its contents.
Make some type names conform to our standard style.
runtime/mercury_stack_layout.h:
Add a new flag in MR_ProcLayouts: a flag that indicates that the
procedure has one or more higher order arguments. The new code in
mercury_stack_trace.c handles procedures with this flag specially:
it does not consider two non-consecutive occurrences of such procedures
on the stack to be necessarily part of the same clique. This is to
avoid having two calls to e.g. list.map in different part of the
program pulling all the procedures between those parts on the stack
into a single clique. (The deep profiler has a very similar tweak.)
Add a pointer to the corresponding part of the compiler.
compiler/hlds_pred.m:
Add a predicate to test whether a predicate has any higher order args.
compiler/stack_layout.m:
When computing the flag in proc layouts, call the new procedure in
hlds_pred.m to help figure it out.
trace/mercury_trace_cmd_backward.c:
Implement the new options of the "retry" command.
trace/mercury_trace_cmd_forward.c:
Implement the new options of the "finish" command.
trace/mercury_trace_cmd_browsing.c:
Implement the "new options of the "level" command.
Implement the new functionality of the "stack" command.
trace/mercury_trace_util.[ch]:
Add some code common to the implementations of the level, retry and
finish commands.
trace/mercury_trace_external.c:
Conform to the changes to the runtime.
doc/user_guide.texi:
Document the debugger's new capabilities.
NEWS:
Announce the debugger's new capabilities.
tests/debugger/mutrec.{m,inp,exp}:
A new test case to test the handling of the stack command
in the presence of cliques.
tests/debugger/mutrec_higher_order.{m,inp,exp}:
A new test case to test the handling of the stack command
in the presence of cliques and higher order predicates.
tests/debugger/Mmakefile:
Enable both new test cases.
|
||
|
|
2239f59b30 |
Fix minor problems in the runtime identified by Visual C.
Branches: main, 11.07 Fix minor problems in the runtime identified by Visual C. runtime/mercury_memory_zones.c: Fix a call to a function that no longer exists. runtime/mercury_stack_trace.h: Fix argument type mismatches between function prototypes and definitions. |
||
|
|
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.
|
||
|
|
70ba4db53d |
Fix a problem introduced in my previous change to the trace directory
Estimated hours taken: 4 Branches: main Fix a problem introduced in my previous change to the trace directory which introduced a dependency between the runtime and the trace directory which broke compilation of the former in high-level C grades. Fix up conversion specifiers in the printf control strings in the trace directory. runtime/mercury_stack_trace.h: Define MR_FrameLimit, MR_SpecLineLimit and MR_AncestorLevel here rather than in the trace directory because the code in the runtime for stack tracing refers to them. (Some code that was only enabled in high-level C grades and referred to the above types was added as part of my last change; this is what broke compilation in those grades.) Rename MR_AncestorLevel to (the more general) MR_Level in the process. runtime/mercury_stack_trace.c: Use MR_FrameLimit and friends in place of ints here. trace/mercury_trace.h: Delete the typedefs for MR_FrameLimit and friends. trace/mercury_trace_cmd_backward.c: trace/mercury_trace_external.c: Conform to the above change. trace/*.c: Change the signedness of conversion specifiers to conform to recent type changes. |
||
|
|
45fd0daf5a |
Implement some of Mark's wish list for making user events more useful.
Estimated hours taken: 20
Branches: main
Implement some of Mark's wish list for making user events more useful.
1. When executing "print *" in mdb, we used to print both the values of all
attributes and the values of all live variables. Since some attributes'
values were given directly by live variables, this lead to some things being
printed twice. This diff eliminates this duplication.
2. At user events, we now print the name of the event. Whether we print the
other stuff we also print at events (the predicate containing the event,
and its source location) is now controlled by a new mdb command,
"user_event_context".
3. We would like different solvers to be compilable independently of one
another. This means that neither solver's event set should depend on the
existence of the events needed by the other solvers. This diff therefore
eliminates the requirement that all modules of the program be compiled with
the same event set specification. Instead, a program may contain modules
that were compiled with different event sets. Each event set is named;
the new requirement is that different named event sets may coexist in the
program (each being used to compile some modules), but two event sets with
the same name must be identical in all other respects as well (we need this
requirement to prevent inconsistencies arising between different versions of
the same event set).
4. We now generate user events even from modules compiled with --trace shallow.
The problem here is that user events can occur in procedures that do not
get caller events and whose ancestors may not get caller events either.
Yet these procedures must still pass on debugger information such as call
sequence numbers and the call depth to the predicate with the user event.
This diff therefore decouples the generation of code for this basic debugger
infrastructure information from the generation of call events by inventing
two new trace levels, settable by the compiler only (i.e. not from the
command line). The trace level "basic_user" is for procedures containing a
user event whose trace level (in a shallow traced module) would otherwise be
"none". The trace level "basic" is for procedures not containing a user
event but which nevertheless may need to transmit information (e.g. depth)
to a user event. For the foreseeable future, this means that shallow traced
modules containing user events will have some debugging overhead compiled
into *all* their procedures.
runtime/mercury_stack_layout.h:
Add a new field to MR_UserEvent structures, giving the HLDS number of
the variable representing each attribute.
Add a new field to module layout structures, giving the name of the
event set (if any) the module was compiled with.
Add the new trace levels to the MR_TraceLevel type.
Update the current layout structure version number.
runtime/mercury_stack_trace.[ch]:
Allow the printing of the containing predicate's name and/or the
filename/linenumber context to be turned off when printing contexts.
Factor out some of the code involved in this printing.
Give a bunch of variables better names.
Rename a type to get rid of unnecessary underscores.
compiler/prog_data.m:
compiler/prog_event.m:
Include the event set name in the information we have about the event
set.
compiler/simplify.m:
Mark each procedure and each module that contains user events
as containing user events.
Use the same technique to mark each procedure that contains parallel
conjunctions as containing parallel conjunctions, instead of marking
the predicate containing the procedure. (Switch detection may eliminate
arbitrary goals, including parallel conjunctions, from switch arms
that are unreachable due to initial insts, and in any case we want to
handle the procedures of a predicate independently from each other
after mode analysis.)
Also, change the code handling generic calls to switch on the generic
call kind, and factor out some common code.
compiler/hlds_module.m:
compiler/hlds_pred.m:
Provide slots in the proc_info and the module_info for the information
gathered by simplify.
compiler/trace_params.m:
Implement the new trace levels described above. This required changing
the signature of some of the predicates of this module.
compiler/code_info.m:
Record whether the compiler generated any trace events. We need to know
this, because if it did, then we must generate a proc layout structure
for it.
compiler/proc_gen.m:
Act on the information recorded by code_info.m.
Factor out the code for generating the call event and its layout
structure, since the conditions for generating this event have changed.
compiler/continuation_info.m:
compiler/call_gen.m:
For each user event, record the id of the variables corresponding to
each argument of a user event.
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
Generate the new field (giving the HLDS variable number of each
attribute) in user event structures, and the new field (event set name)
in module layout structures.
Allow the call event's layout structure to be missing. This is needed
for user events in shallow traced modules.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compiler.m:
Rename the option for specifying event sets from --event-spec-file-name
to --event-set-file-name, since it specifies only one event set, not
all events.
compiler/jumpopt.m:
Give some predicates better names.
compiler/dep_par_conj.m:
compiler/deforest.m:
compiler/granularity.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/liveness.m:
compiler/modes.m:
compiler/opt_debug.m:
compiler/optimize.m:
compiler/size_proc.m:
compiler/stack_alloc.m:
compiler/store_alloc.m:
compiler/table_gen.m:
compiler/trace_gen.m:
compiler/typecheck.m:
Conform to the changes above.
doc/mdb_categories:
Mention the new mdb command.
doc/user_guide.texi:
Update the documentation of user events to account for the changes
above.
trace/mercury_event_parser.y:
trace/mercury_event_scanner.l:
Modify the grammar for event set specifications to a name for the
event set.
trace/mercury_event_spec.[ch]:
Instead of recording information about event sets internally
in this module, return a representation of each event set read in
to the callers, for them to do with as they please.
Include the event set name when we print the Mercury term for
compiler/prog_event.m.
trace/mercury_trace.c:
Do not assume that every procedure that contains an event contains a
call event (and hence a call event layout structure), since that
is not true anymore.
trace/mercury_trace_cmd_parameter.[ch]:
Implement the new mdb command "user_event_context".
trace/mercury_trace_cmd_internal.[ch]:
Include "user_event_context" in the list of mdb commands.
Print the user event name at user events. Let the current setting
of the user_event_context mdb command determine what else to print
at such events.
Instead of reading in one event set on initialization, read in
all event sets that occur in the program.
trace/mercury_trace_tables.[ch]:
Allow the gathering of information for more than one event set
from the modules of the program.
trace/mercury_trace_vars.[ch]:
For each attribute value of a user event, record what the HLDS variable
number of the attribute is. When printing all variables at an event,
mark the variable numbers of printed attributes as being printed
already, causing the variable with the same number not to be printed.
Include the name of the variable (if it has one) in the description
of an attribute. Without this, users may wonder why the value of the
variable wasn't printed.
trace/mercury_trace_cmd_browsing.[ch]:
Pass the current setting of the user_event_context mdb command to
runtime/mercury_stack_trace.c when printing the context of an event.
tests/debugger/user_event_shallow.{m,inp,exp}:
New test case to test the new functionality. This test case is the same
as the user_event test case, but it is compiled with shallow tracing,
and its mdb input exercises the user_event_context mdb command.
tests/debugger/user_event_spec:
tests/invalid/invalid_event_spec:
Update these event set spec files by adding an event set name.
tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
Enable the new test case.
tests/debugger/user_event.exp:
Update the expected output of the old user event test case, which now
prints event names, but doesn't print attribute values twice.
tests/debugger/completion.exp:
Expect the new "user_event_context" mdb command in the command list.
tests/debugger/mdb_command_test.inp:
Test the existence of the documentation for the new mdb command.
tests/invalid/Mercury.options:
Conform to the name change of the --event-spec-file-name option.
|
||
|
|
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). |
||
|
|
d1c13d57c5 |
Fix some layout issues in these files. There are no algorithmic
Estimated hours taken: 0.3 Branches: main runtime/mercury_accurate_gc.h: runtime/mercury_agc_debug.h: runtime/mercury_array_macros.h: runtime/mercury_construct.h: runtime/mercury_deconstruct.h: runtime/mercury_init.h: runtime/mercury_layout_util.h: runtime/mercury_stack_layout.h: runtime/mercury_stack_trace.h: runtime/mercury_trail.h: Fix some layout issues in these files. There are no algorithmic changes. |
||
|
|
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. |
||
|
|
4d443a5c9e |
Make the stack and nondet_stack commands in mdb limit the number of lines
Estimated hours taken: 3
Branches: main
Make the stack and nondet_stack commands in mdb limit the number of lines
printed, instead of the number of stack frames reported on.
runtime/mercury_stack_trace.[ch]:
Add a mechanism to limit the number of lines printed by stack traces.
trace/mercury_trace_internal.c:
Change the existing "stack" and "nondet_stack" mdb commands to make the
integer argument specify the number of lines printed by default, not
the number of stack frames reported on, since this is usually what is
wanted. The number of stack frames N to be reported on can still be
specified, via the new option -fN.
Add a new mdb command, "stack_default_limit", that specifies the
default number of lines to print in stack traces.
trace/mercury_trace_external.c:
Conform to the changed interfaces in mercury_stack_trace.h.
doc/user_guide.texi:
Document the changes to mdb commands.
tests/debugger/mdb_command_text.inp:
Test the documentation of the new command.
tests/debugger/completion.exp*:
Expect to see the new stack_default_limit command listed.
tests/debugger/queens.exp*:
Expect the new meaning of the stack command.
tests/debugger/nondet_stack.{inp,exp*}
Use the new -f option of the nondet_stack command to specify the
printing of the same number of frames as before. Update the expected
accordingly.
|
||
|
|
f71532a398 |
Add an mdb command, all_procedures, for listing all the procedures in the
Estimated hours taken: 2
Branches: main
Add an mdb command, all_procedures, for listing all the procedures in the
program. It has two options: -u or --uci for listing unify, compare, index and
init predicates, and -s or --separate for printing the various parts of
procedure names in separate fields, for automatic processing (e.g. by awk
scripts).
trace/mercury_trace_internal.c:
Implement all_procedures.
Fix a couple of small bugs: a wrong help category argument in an option
processing call, and a NULL completer function.
trace/mercury_trace_tables.[ch]:
Provide a function that is the guts of all_procedures.
Fix the code for handling the specification of unify, compare and
index procedures to also handle init procedures.
doc/user_guide.texi:
Document all_procedures.
runtime/mercury_stack_trace.[ch]:
Add a new function for printing procedure ids for all_procedures -s.
Fix the code for printing unify, compare and index predicates to also
handle init predicates.
tests/debugger/solver_test.{m,inp,exp}:
A new test case to test the fix of the printing of init predicates.
tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
Add the new test case.
tests/debugger/mdb_command_test.inp:
tests/debugger/completion.exp:
Update these files to account for the new mdb command.
|
||
|
|
e6d82c9bd4 |
Added trusted' and untrust' commands. Also allowed individual predicates to
Estimated hours taken: 10 Branches: main Added `trusted' and `untrust' commands. Also allowed individual predicates to be trusted. browser/declarative_debugger.m Exported predicates to add a trusted predicate or function, remove a trusted object and return a list of the trusted objects. browser/declarative_oracle.m Changed trusted set so it can also contains individual predicates and functions. Added predicates to add a trusted predicate or function to the set, remove a trusted object from the set and return a list of the trusted objects. doc/mdb_categories Added dd category. doc/user_guide.texi Documented `untrust' and `trusted' commands. runtime/mercury_stack_trace.c runtime/mercury_stack_trace.h Added a print_mode argument to MR_print_proc_id_internal, so that printing of mode information can be turned on or off. When a list of matching predicates for the trust command is shown then mode information is superfluous, since a predicate/function is trusted, not a procedure. Added MR_print_pred_id to print predicate id - i.e. proc id without the mode info. tests/debugger/completion.exp New commands shown in completion list. tests/debugger/completion.inp Added a space, since a --More-- prompt is now displayed when showing all the commands. tests/debugger/mdb_command_test.inp untrust and trusted added. tests/debugger/declarative/trust.exp tests/debugger/declarative/trust.inp Testing of new commands. trace/mercury_trace_declarative.c trace/mercury_trace_declarative.h Added functions to add a trusted predicate and remove a trusted object. Also added a function to print a list of the trusted objects. These all call the predicates exported from declarative_debugger.m. trace/mercury_trace_internal.c Added handlers for `trusted' and `untrust' commands. trace/mercury_trace_tables.c trace/mercury_trace_tables.h Added a function to filter out only the user predicates and functions from a list of procedures. This filters out uci procs and also filters out all procs with a mode number > 0 (thus leaving one proc for each predicate/function). This is used when displaying the predicates matching an ambiguous proc-spec with a trust command. NEWS Updated NEWS file. |
||
|
|
9c9676fac0 |
Fix problems with namespace cleanliness on ender.
Estimated hours taken: 0.5 Branches: main Fix problems with namespace cleanliness on ender. runtime/mercury_library_types.h: runtime/mercury_signal.h: runtime/mercury_stack_trace.h: runtime/mercury_std.h: trace/mercury_trace_vars.h util/mkinit.c: Make sure that we include mercury_regs.h before system header files with functions. |
||
|
|
8b9d436cbb |
More improvements for minimal model tabling.
Estimated hours taken: 12
Branches: main
More improvements for minimal model tabling.
runtime/mercury_engine.[ch]:
Provide a debug flag to control the printing of debug stack slots
in nondet stack dumps.
runtime/mercury_stack_trace.[ch]:
Provide a mechanism that allows a dump of the nondet stack to print
the principal debugging stack slots of the stack frames of procedures
that were compiled with debugging, to help debug problems where
these are overwritten during stack segment saves/restores.
Add a mechanism for limiting the output of a nondet stack trace
to a segment of the nondet stack.
runtime/mercury_minimal_model.[ch]:
Limit the output of a diagnostic nondet stack trace to just the
segment being saved or restored.
Provide a label layout structure for the entry point of the suspend
predicate, since this is necessary for correct nondet stack traces
at suspensions and resumptions.
Store the layout structure of the top nondet stack frame with each
saved state, to allow the saved nondet stack segment to be dumped
at resumptions as well as suspensions.
Fix an old bug: when extending a saved stack segment, use the same
algorithm for determining its lower bound as when the stack segment
was created in the first place.
Factor out some repeated definitions.
Note problems to be fixed later.
Improve debugging output.
runtime/mercury_stacks.[ch]:
Move the documentation of the generator stack, the cut stack and the
pneg stack from the source file to the header file, and expand it
considerably.
Make the routines for printing entries of these stacks generate more
consistently formatted output.
Simplify some code.
runtime/mercury_stack_layout.h:
Provide a macro for use by mercury_minimal_model.c.
runtime/mercury_trace_base.[ch]:
Save and restore the global variables holding event numbers,
call sequence numbers and call depths across debugging Mercury code.
We already used to do this for Mercury code invoked by the debugger,
but now that we can invoke Mercury code to print the values of
variables as diagnostics from within the suspend and resume predicates
*outside* the debugger, we need to do it more generally.
trace/mercury_trace.c:
Fix a bug: provide the layout structure of the current procedure
to the diagnostic routines for minimal model tabling even if the
debugger doesn't stop at that procedure.
trace/mercury_trace_internal.c:
Add two new mdb commands to help debug minimal model tabling.
The "mm_stack" command has the same effect as the existing commands
"gen_stack", "cut_stack" and "pneg_stack" executed in sequence.
The "debug_vars" command prints the counters for event numbers,
call sequence numbers and call depths, both from their global variables
and their saved copies, for debugging problems where they are
overwritten, such as the one fixed by the changes to
mercury_trace_base.[ch] above.
Reorder some code for consistency.
trace/mercury_trace_util.[ch]:
Add a function to implement the "debug_vars" command.
doc/user_guide.texi:
Document the new mdb commands.
doc/mdb_categories:
Add the new mdb commands to the list of developer commands, as well
some others previously left out.
tests/debugger/mdb_command_test.inp:
Test the documentation of the new mdb commands.
tests/tabling/combine.m:
Change the code of this test case to what was intended, so that it now
matches the old expected output.
tests/tabling/completed_consumer_in_solutions.{m,exp}:
New test case, an easier version of consumer_in_solutions.
tests/tabling/consumer_in_commit.{m,exp}:
Extend this test case and update the expected output; we can execute
both the original code and the extension without runtime exceptions.
tests/tabling/seq2.m:
Fix Kostis's new test case.
tests/tabling/seq4.exp:
Fix the expected output of Kostis's new test case.
tests/tabling/Mmakefile:
Enable the new test cases, and some old test cases that we now pass.
|
||
|
|
b274728218 |
More improvements to LLDS accurate GC.
Estimated hours taken: 8 Branches: main More improvements to LLDS accurate GC. runtime/mercury_accurate_gc.c: Rewrite the LLDS accurate GC stack traversal code using MR_stack_walk_step() and MR_traverse_nondet_stack_from_layout(). The previous code had some serious bugs. runtime/mercury_stack_trace.h: runtime/mercury_stack_trace.c: Don't pass `level_number' to the traversal function for MR_traverse_nondet_stack_from_layout(). It's not needed. runtime/mercury_stack_trace.c: Add a comment, and an assertion. |
||
|
|
b31ef626ce |
A first step towards fixing a serious problem with the LLDS accurate
Estimated hours taken: 2 Branches: main A first step towards fixing a serious problem with the LLDS accurate garbage collector where it does not handle traversing the nondet stack correctly. This step does not change any algorithms; it just refactors some code to make it more reusable. runtime/mercury_stack_trace.h: runtime/mercury_stack_trace.c: Define a new function MR_traverse_nondet_stack_from_layout, which is like MR_dump_nondet_stack_from_layout, except that instead of dumping each frame, it instead just calls a caller-supplied traversal function on each frame. This is for (eventual) use by mercury_accurate_gc.c. runtime/mercury_accurate_gc.c: Add an XXX comment, saying that we should use MR_traverse_nondet_stack_from_layout(). |
||
|
|
c743626923 |
Various bug fixes for accurate GC in LLDS grades:
Estimated hours taken: 4 Branches: main Various bug fixes for accurate GC in LLDS grades: runtime/mercury_wrapper.c: Fix two bugs in my last change: - use MR_NATIVE_GC rather than the non-existent MR_ACCURATE_GC - use %lf rather than %f when calling scanf() for a double runtime/mercury_accurate_gc.c: - Fix some bugs with traversing the nondet stack. - Make sure that we round the active heap size up to a multiple of the page size, otherwise mprotect() won't work. - Avoid some casts by using type `MR_Code **' rather than `MR_Word *' for the saved_success_location variable. - Comment out some unused code. runtime/mercury_stacks.h: Add MR_curfr_slot_addr(), which is like MR_curfr_slot() except that it returns the slot's address, for use by mercury_accurate_gc.c. (Using "&MR_curfr_slot(...)" results in an "invalid lvalue" error from GCC, despite the use of MR_LVALUE_CAST in its definition.) runtime/mercury_stack_trace.h: Add some comments. runtime/mercury_stack_trace.c: Fix some incorrect indentation. compiler/stack_layout.m: Fix a cut-and-paste error. |
||
|
|
2bf6095986 |
Add a mechanism to limit the output from the "stack" and "nondet_stack"
Estimated hours taken: 4
Branches: main
Add a mechanism to limit the output from the "stack" and "nondet_stack"
mdb commands to a given number of stack frames. (We may later add a
mechanism to limit the output to a given number of lines, but that
is significantly harder, since it requires knowing how wide the
terminal is and which lines exceed that width.)
NEWS:
Mention the new capability.
doc/user_guide.texi:
Document the new optional arguments of the two commands.
trace/mercury_trace_internal.c:
Implement the new optional arguments.
Fix some places where we weren't checking that a natural number
we were expecting wasn't negative or followed by trailing garbage.
runtime/mercury_stack_trace.[ch]:
Add limit parameters to the stack trace functions, and obey them.
trace/mercury_trace_external.c:
Pass the new parameters.
tests/debugger/queens.{inp,exp*}:
Add tests of "stack N" to the supplied input, and update the expected
outputs accordingly. Remove the .exp3 file, which cannot have been
used recently (it still has raw event numbers, not the standardized
ones the Mmakefile now calls for).
tests/debugger/nondet_stack.{inp,exp*}:
Add tests of "nondet_stack N" to the supplied input, and update
the expected outputs accordingly.
|
||
|
|
b7c4a317e9 |
Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4 Branches: main Add MR_ prefixes to the remaining non-prefixed symbols. This change will require all workspaces to be updated The compiler will start generating references to MR_TRUE, MR_bool, etc., which are not defined in the old runtime header files. runtime/mercury_std.h: Add MR_ prefixes to bool, TRUE, FALSE, max, min, streq, strdiff, strtest, strntest, strneq, strndiff, strntest, NO_RETURN. Delete a commented out definition of `reg'. runtime/mercury_tags.h: Add an MR_ prefix to TAGBITS. configure.in: runtime/mercury_goto.h: runtime/machdeps/i386_regs.h/mercury_goto.h: Add an MR_ prefix to PIC. runtime/mercury_conf_param.h: Allow non-prefixed PIC and HIGHTAGS to be defined on the command line. runtime/mercury_bootstrap.h: Add backwards compatibility definitions. RESERVED_MACRO_NAMES: Remove the renamed macros. compiler/export.m: compiler/ml_code_gen.m: Use MR_bool rather than MR_Bool (MR_Bool is meant to be for references to the Mercury type bool__bool). runtime/mercury_types.h: Add a comment the MR_Bool is for references to bool__bool. */*.c: */*.h: */*.m: Add MR_ prefixes. |
||
|
|
fbfd4970df |
Make the debugging of minimal model tabling easier by providing a mechanism
Estimated hours taken: 32
Branches: main
Make the debugging of minimal model tabling easier by providing a mechanism
to print the contents of the nondet stack, *including* the values of the
variables in its stack frames, even for frames which are not ancestors
of the currently executing call.
runtime/mercury_stack_trace.[ch]:
Add functions for traversing the nondet stack, and for keeping track of
through which label control returns to each nondet stack frame, so that
we know which label's layout structure to interpret the stack frame's
contents. For some, this will be the return label of a call; for
others, it will be the label of a resumption point stored in a
redoip slot.
Rename an old function to allow the new one to fit into our naming
scheme.
runtime/mercury_stack_trace.[ch]:
runtime/mercury_tabling.c:
library/exception.m:
trace/mercury_trace.c:
Add MR_ prefixes to the values of the enum returned by
MR_stack_walk_step.
Rename references to the renamed function.
runtime/mercury_conf_param.h:
Add macros for debugging label names and for debugging retries (which
needs label names, just as debugging tabling does).
Add a macro for controlling whether mercury_debug.c prints raw
addresses as well as offsets (for stack pointers) or label names (for
labels). The raw pointers can be useful in debugging, but they need to
be turned off in test cases one wants to be reproducible.
runtime/mercury_label.h:
runtime/mercury_conf_param.h:
Move the MR_NEED_ENTRY_LABEL_ARRAY and MR_NEED_ENTRY_LABEL_INFO macros
from mercury_label.h to mercury_conf_param.h, since mercury_debug.c
also needs them now.
runtime/mercury_debug.c:
addresses as well as offsets (for stack pointers) or label names (for
labels). The raw pointers can be useful in debugging, but they need to
be turned off in test cases one wants to be reproducible.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
util/mkinit.c:
Add a global variable pointing to a function through which the stack
walk code in runtime/mercury_stack_trace.c can invoke code from the
debugger to print the values of the variables in nondet stack frames
without breaking the rule prohibiting references to the trace directory
from the runtime directory.
runtime/mercury_wrapper.c:
Define the succip of the dummy frame at the bottom of the nondet stack,
to avoid dereferencing a garbage pointer during detailed stack dumps.
runtime/mercury_goto.h:
Add a mechanism for always registering the name of a specific label,
even if label names are not being registered in general. This mechanism
is intended to be used for labels such as do_fail, which occur
frequently in nondet stack traces.
runtime/mercury_context.c:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
Use this mechanism for the labels defined in these modules.
library/builtin.m:
Define type_ctor_infos for the pseudotypes representing nondet stack
frame slots unconditionally, since the debugger may now need them.
trace/mercury_trace.c:
Add conditionally enabled to code to make debugging retry easier.
trace/mercury_trace_internal.c:
Add a -d option to the nondet_stack command that causes it to print
detailed nondet stack dumps, including the names and values of the
variables in each nondet stack frame.
trace/mercury_trace_vars.c:
Provide a mechanism for printing the variables of a stack frame
even when that stack frame is not an ancestor of the current call.
doc/user_guide.texi:
Document the new option of the nondet_stack command.
tests/debugger/nondet_stack.{m,inp,exp,exp2}:
A new test case to test "nondet_stack -d".
tests/debugger/Mmakefile:
Enable the new test case.
|
||
|
|
2498d9d3fd |
Instead of generating the layout structures of labels, procs and modules
Estimated hours taken: 36 Instead of generating the layout structures of labels, procs and modules as rvals, generate them almost entirely as C structures. This will make future modifications much easier, since mismatches between what the runtime expects and what the compiler generates will now be pointed out by the C compiler. (It also reduces the size of the C source files generated with debugging enabled by about 5%.) Layout structures contain a few components that are not well-typed in C; we continue to generate these as rvals. Closure layout structures used to have a well-typed part and a non-well-typed part. We now generate the well-typed part as a separate structure, pointed to from the other. We also extend the well-typed part, so that instead of just giving the name the called procedure, it also identifies the source location where the closure was constructed. This could be useful for the debugger and for deep profiling. This diff also includes a change to get the compiler to bootstrap with lcc in grade none.gc.debug.tr: initializing the string tables in module layouts not as a string but as an array of characters. runtime/mercury_stack_layout.h: Reorganize the definitions of layout structures. Rename Stack_Layout_Entry structures as Proc_Layout structures, and Stack_Layout_Label structures as Label_Layout structures. (The debugger paper refers to the structures by the new names.) Fold the Stack_Layout_Vars structure into the structure that contains it, the Label_Layout structure. Add a Closure_Id structure that contains a Proc_Id structure as well as extra information identifying the source location where the closure was created. Create "short" versions of the Proc_Layout structures, which contain only the first one or two of the three groups of fields. Previously, the Mercury compiler would define new C types when it generated such short structures. Since we are not defining new C types anymore, there must be a C type for every kind of structure the Mercury compiler can generate. We now also have separate variants for the layouts of user-defined and compiler-generated procedures, since the format of their procedure id information is different. While the runtime system refers to their procedure id information through a union, the C types of the structures generated by the Mercury compiler do not use a union, since a union cannot be initialized through its second member. Make the constant fields of structures const, since we now generate values of those structure types, and initialize them with constant data. Move the documentation of layout structures here from stack_layout.m. runtime/mercury_ho_call.h: Instead of bodily including an MR_Proc_Id structure in closures, include a pointer to the more detailed MR_Closure_Id structure. runtime/mercury_accurate_gc.c: runtime/mercury_agc_debug.c: runtime/mercury_init.h: runtime/mercury_label.[ch]: runtime/mercury_layout_util.[ch]: Minor updates to conform to changes in mercury_stack_layout.h. runtime/mercury_goto.h: Use separate naming schemes for label layout structures and proc layout structures. library/exception.m: Minor updates to conform to changes in mercury_stack_layout.h. compiler/layout.m: A new module that defines data structures for label, proc and module layout structures and for closure id structures. compiler/layout_out.m: A new module that converts the Mercury data structures of layout.m into declarations and definitions of C data structures. compiler/stack_layout.m: Generate the new layout structures instead of rvals. Move the documentation of layout structures from here to runtime/mercury_stack_layout.h, since this module is no longer aware of some of their details. compiler/llds.m: Make layout structures a separate kind of compiler-generated data. compiler/llds_out.m: Remove the code for the output of layout structures; call layout_out.m instead. compiler/llds_out.m: compiler/rtti_out.m: Turn some predicates into functions. compiler/code_gen.m: compiler/code_info.m: compiler/llds.m: compiler/mercury_compile.m: compiler/unify_gen.m: Instead of handling closure layouts like other static data, handle them separately. Add a counter to the code_info structure in order to allow closure id structures to be identified uniquely by a pair consisting of the id of the procedure that generates them and a closure sequence number within that procedure. compiler/llds_common.m: Look for common rvals among the rvals in layout structures. compiler/opt_debug.m: Generate developer-friendly names for layout structure references. browser/dl.m: Update the code for constructing closure layouts. |
||
|
|
090552c993 |
Make everything in the runtime use MR_ prefixes, and make the compiler
Estimated hours taken: 10 Make everything in the runtime use MR_ prefixes, and make the compiler bootstrap with -DMR_NO_BACKWARDS_COMPAT. runtime/mercury_*.[ch] Add MR_ prefixes to all functions, global variables and almost all macros that could pollute the namespace. The (intentional) exceptions are 1. some function, variable, type and label names that already start with MR_, mercury_, Mercury or _entry; 2. some standard C macros in mercury_std.h; 3. the macros used in autoconfiguration (since they are used in scripts as well as the runtime, the MR_ prefix may not be appropriate for those). In some cases, I deleted things instead of adding prefixes if the "things" were obsolete and not user visible. runtime/mercury_bootstrap.h: Provide MR_-less forms of the macros for bootstrapping and for backward compatibility for user code. runtime/mercury_debug.[ch]: Add a FILE * parameter to a function that needs it. compiler/code_info.m: compiler/export.m: compiler/fact_table.m: compiler/llds.m: compiler/llds_out.m: compiler/pragma_c_gen.m: compiler/trace.m: Add MR_ prefixes to the C code generated by the compiler. library/*.m: Add MR_ prefixes to handwritten code. trace/mercury_trace_*.c: util/mkinit.c: Add MR_ prefixes as necessary. extras/concurrency/semaphore.m: Add MR_ prefixes as necessary. |
||
|
|
fdccd65e30 |
The debugger's retry command at the moment works only from a final port for
Estimated hours taken: 60
The debugger's retry command at the moment works only from a final port for
the call to be retried, the reason being that the RTTI does not have the
information required to make sure that the state of the stacks is reset
correctly. If you invoke retry from a non-final port, the current
implementation skips forward to a final port and then does the retry;
this does not work if you get a core dump or a infinite loop during the forward
skip. This change adds the required info to the RTTI and thus enables
direct retries from the middle of calls.
The information added has two components. First, if a procedure that lives on
the nondet stack allocates any temporary nondet stack frames, then it must
record the old value of maxfr in a stack slot so that retry can restore it.
Second, if a procedure is tabled, then it must record the call table tip node
corresponding to the actual input arguments, so we can reset this node to
uninitialized (if we don't, then the retried call will find the active call
marker and report an infinite loop error).
The support for retries across minimal model calls is not finished yet.
Finding out what the right thing to do in such cases is a research project,
one that cannot even be started until minimal model tabling works reliably
in the *absence* of retries. However, such retries do grossly wrong things
at the moment; this change is a definite improvement. It attempts to perform
the retry from the fail port, since that is the only time when the minimal
model tabling data structures are quiescent. The "fail" command I added to
the debugger command set to let this be done is not complete yet and is
therefore undocumented; the problem is that a call to a model_non predicate
in a committed choice context will not get to the fail port. I added goal paths
to return layouts so that we will eventually be able to tell when execution
leaves a committed choice context surrounding an ancestor of a model_non
predicate call, but this functionality is not yet implemented.
compiler/stack_layout.m:
Generate the three new fields: the evaluation method, (maybe) the id
of the stack slot containing the saved value of maxfr, and (maybe)
the id of the stack slot containing the call table tip.
compiler/continuation_info.m:
Record the information about the new fields for later use by
stack_layout.m.
Add a new field to record the goal path of calls for their return
layouts.
Fix a screwed comment for the continuation_info data structure.
compiler/llds.m:
Add a new field to call() instructions to hold the goal path of the
call.
Add a utility function for use by trace.m.
compiler/call_gen.m:
Fill in this new field.
compiler/trace.m:
compiler/live_vars.m:
Reserve the fixed stack slot for the saved maxfr if necessary,
and if the call table tip node is needed, make sure that the variable
holding its address is allocated a low-numbered stack slot (otherwise,
its number may not fit into the MR_int_least8_t field in the
proc_layout).
compiler/trace.m:
If necessary, fill in the saved maxfr slot.
If necessary, initialize the call table tip slot.
compiler/hlds_goal.m:
Add a goal feature which marks its goal as defining the variable
representing the call table tip node.
Add a field to the goal path step representing quantification;
the field says whether the quantification changes the determinism of
the goal (i.e. whether it cuts away solutions).
compiler/hlds_pred.m:
compiler/hlds_out.m:
Add two fields to proc_infos which (a) record which variable, if any,
holds the call table tip node, and (b) record whether the procedure's
layout structure needs to reserve a slot for the saved value of maxfr.
compiler/table_gen.m:
Put this feature on the appropriate goal.
Also, rename a predicate to make it reflect its purpose better.
compiler/code_gen.m:
Generate code to put the call table tip variable in its stack slot
immediately after it has been generated.
Add a sanity check to ensure that if a procedure that lives on the det
stack can create a temporary nondet frame, and debugging is enabled,
then it did have a stack slot reserved for the saved maxfr.
compiler/code_util.m:
Add a predicate to make a conservative prediction of whether a
procedure may allocate a temporary nondet stack frame. We cannot
just generate the code and see, because the code generator needs to
know which variables live in which stack slots, and we cannot decide
that until we know whether we need a stack slot for the saved value of
maxfr.
Make an unrelated predicate semidet procedure use a det helper, in
order to make it more robust in the face of changes to the HLDS
(e.g. it was missing code for handling bi_implications).
compiler/code_info.m:
Record whether a procedure has in fact created a temporary nondet stack
frame.
compiler/handle_options.m:
Disable hijacks if debugging is enabled. The code we now use to
restore the stacks for direct retries works only if the retry does not
"backtrack" over a hijacked nondet stack frame whose hijack has not
been undone. Note that code compiled without debugging may still hijack
nondet stack frames. Execution may reemerge from the nondebugged region
in one of two ways. If the nondebugged code returns, then it will have
undone hijack, and the retry code will work. If the nondebugged code
calls debugged code, there will be a region on the stacks containing
no debugging information, and the retry command will refuse to perform
retries that go into or beyond this region. Both cases preserve
correctness.
compiler/*.m:
Trivial changes to conform to changes in data structures.
runtime/mercury_stack_layout.h:
Add three new fields to proc layouts: the numbers of the stack slots
(if any) storing the saved maxfr and the call table tip, and a
representation of the procedure's evaluation method.
runtime/mercury_stack_trace.[ch]:
Now that return layouts contain goal paths, print them in stack dumps
only if the include_trace_data flag is set (in mdb, this requires the
-d flag of the "stack" command).
Pass this flag around directly, instead of encoding its value in
the NULL vs non-NULL values of sp and curfr.
runtime/mercury_regorder.h:
Provide a mechanism to access the values of the first few rN registers
from a save area, for use in debugging low-level C code in the runtime
and the trace directories.
trace/mercury_trace.[ch]:
Reimplement MR_trace_retry to allow retries from the middle.
If the stack segment being retried over contains minimal model
procedures, we must still arrange to skip to the end of the retried
call. If this call is a minimal model generator, skipping to just any
final port is not sufficient to guarantee correctness on retry; to
ensure that subgoal is complete, we must skip to a fail port.
trace/mercury_trace.[ch]:
trace/mercury_trace_internal.c:
Implement a debugger command, "fail", which skips to the fail port or
the exception port of the specified ancestor. Since procedures that are
not model_non are not guaranteed to get to such a port, this
command reports an error if the specified call is not model_non.
Actually, even calls to model_non procedures may not get to the fail
port, as explained above; this is why the command is not yet
documented.
trace/mercury_trace.c:
trace/mercury_trace_util.[ch]:
Move some functions to print parts of the Mercury abstract machine
state from mercury_trace to mercury_trace_util, so that they are
available for use in debugging e.g. mercury_trace_declarative.
trace/mercury_trace_internal.c:
trace/mercury_trace_external.c:
trace/mercury_trace_declarative.c:
Use the new implementation of retries. At the moment, only the
internal debugger implements the full functionality. The declarative
debugger issues retry commands only from situations where the missing
functionality is not (yet) needed. The external debugger should
continue to work correctly, but Erwan may wish to update it to
exploit the availability of the fail command.
trace/mercury_trace*.[ch]:
Fix MR_prefixes, and a signed/unsigned mismatch.
doc/user_guide.texi:
Document the new "fail" command, but comment it out for now.
tests/debugger/retry.{m,inp,exp,exp2}:
A new test case for exercising retry.
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/*.exp:
Update the expected output, given the extra info now output e.g. for
exception events and detailed stack traces.
|
||
|
|
e60f641d9b |
Make it possible to save the state of a debugger session wrt break points
Estimated hours taken: 6 Make it possible to save the state of a debugger session wrt break points and aliases in a file that can be sourced in another debugger session to restore the state. trace/mercury_trace_internal.c: Add a new mdb command, "save <filename>", to save mdb's state to the named file. Allow the "disable", "enable" and "delete" commands to be given without arguments; such invocations refer to the most recently created breakpoint. The extension to "disable" is required by the implementation of the "save" command; the others are for symmetry. Allow the user to speficy an option to the source command that tells mdb not to complain if the named file cannot be processed. This should allow people to put into .mdbrc files commands to source saved state files if they exist and not get complaints if they don't. Make several messages conform to our convention that error messages start with "mdb: ". trace/mercury_trace_spy.[ch]: Add code to implement the part of the "save" command concerned with breakpoints. Unfortunately, there is no simple way to save the specification of breakpoints created with "break here", so for the time being they are not saved. This should not be too much of a problem, since such breakpoints are rarely used. Maintain a variable that identifies the most recently added breakpoint, if any. Also move the function to print out breakpoints here from mercury_trace_internal.c, in order to centralize knowledge about breakpoints here. trace/mercury_trace_alias.[ch]: Add code to implement the part of the "save" command concerned with aliases. Fix some occurrences of an old bug: use MR_free, not free, to free strings allocated with MR_copy_string. trace/mercury_stack_trace.[ch]: Add a version of MR_print_proc_id that prints proc ids in a form suitable for mdb procedure specifications. doc/user_guide.texi: Document the "save" command and the new usage modes of the other modified commands. tests/debugger/mdb_command_test.inp: Test the existence of documentation for the "save" command. tests/debugger/polymorphic_output.exp: Update an expected error message. |
||
|
|
db64a3588d |
Add MR_ prefixes to the types used when generating C code.
Estimated hours taken: 4 Add MR_ prefixes to the types used when generating C code. This means types such as Word, String, Bool, Float become MR_Word, MR_String, MR_Bool, MR_Float. Also define MR_Box for both the LLDS and MLDS backends so we can use it uniformly. This is very important in environments where String or Bool have already been used as system types (for example, managed C++). And besides, we should do it anyway as part of the grand namespace cleanup. I have fixed all of the uses of the non-prefixed types in the runtime and trace directories. I haven't done it for the library and compiler directories yet (no promises that I will do it in future either). But if you see a non-prefixed type in code from now on, please consider it a bug and fix it. mercury_bootstrap.h contains #defines to map the non-prefixed types into the prefixed ones. Like many of the other namespace cleaning backwards compatibility macros, this can be turned off with MR_NO_BACKWARDS_COMPAT. This shouldn't break any code, but this kind of change affects so many things that of course there could be problems lurking in there somewhere. If you start getting errors from the C compiler after this change is installed, you will want to make sure you at least have the runtime system updated so that you are getting the backwards compatibility definitions in mercury_bootstrap.h. Then if you continue to have problems you can bug me about it. compiler/export.m: compiler/llds_out.m: compiler/mlds_to_c.m: Use MR_Word, MR_Float, MR_Bool, etc when generating C. doc/reference_manual.texi: Update the reference manual to talk about MR_Word, MR_String, MR_Char, etc. runtime/mercury_bootstrap.h: Add bootstrapping typedefs. runtime/*: trace/*: Change Word, Float, Bool, Code, String, etc to MR_Word, MR_Float, MR_Bool, MR_Code, MR_String. |
||
|
|
f87f9d2120 |
Ensure that the none.gc and none grades compile using a compiler
Estimated hours taken: 24
Ensure that the none.gc and none grades compile using a compiler
other than gcc. This is not completely tested as lcc on linux can't
generate code for boehm_gc, and 'cc -std1' on the alpha runs out of
memory while trying to link the compiler. However the compiler does
bootstrap using just gcc and also with lcc with boehm_gc compiled by
gcc.
configure.in:
-Wl,opt1,opt2 syntax is not supported by lcc instead use -Wlopt1
-Wopt2.
compiler/export.m:
Only output a label declaration if that label is exported, as the
static label declarations are not legal C.
library/io.m:
compiler/stack_layout.m:
Replace escape sequence \x with \\x in pragma c code.
library/array.m:
library/std_util.m:
Define what the struct is before using it, so the correct size for the
struct can be calculated.
library/private_builtin.m:
Replace escape sequence \x with \\x in pragma c code.
Ensure that there is at least one local variable so that the
structure definition for holding the local vars contains something.
runtime/mercury_faultaddr.h:
Remove an unnecessary cast.
runtime/mercury_reg_workarounds.h:
#include sys/time.h for FD_ZERO().
runtime/mercury_stack_trace.h:
Remove an extraneous ',' which was causing warnings.
|
||
|
|
f0964815a3 |
Support line numbers in the debugger. You now get contexts (filename:lineno
Estimated hours taken: 40
Support line numbers in the debugger. You now get contexts (filename:lineno
pairs) printed in several circumstances, and you can put breakpoints on
contexts, when they correspond to trace events or to calls. The latter are
implemented as breakpoints on the label layouts of the return sites.
This required extending the debugging RTTI, so that associated with each
module there is now a new data structure listing the source file names that
contribute labels with layout structures to the code of the module. For each
such source file, this table gives a list of all such labels arising from
that file. The table entry for a label gives the line number within the file,
and the pointer to the label layout structure.
compiler/llds.m:
Add a context field to the call instruction.
compiler/continuation_info.m:
Instead of the old division of continuation info about labels into
trace ports and everything else, divide them into trace ports, resume
points and return sites. Record contexts with trace ports, and record
contexts and called procedure information with return sites.
compiler/code_info.m:
Conform to the changes in continuation_info.m.
compiler/options.m:
Add a new option that allows us to disable the generation of line
number information for size benchmarking (it has no other use).
compiler/stack_layout.m:
Generate the new components of the RTTI, unless the option says not to.
compiler/code_gen.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
Include contexts in the information we gather for the layouts
associated with the events we generate.
compiler/call_gen.m:
Include contexts in the call LLDS instructions, for association
with the return site's label layout structure (which is done after
code generation is finished).
compiler/handle_options.m:
Delete the code that tests or sets the deleted options.
compiler/mercury_compile.m:
Delete the code that tests the deleted options.
compiler/basic_block.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/value_number.m:
compiler/vn_*.m:
Trivial changes to conform to the changes to llds.m.
compiler/jumpopt.m:
Do not optimize away jumps to labels with layout structures.
The jumps we are particularly concerned about now are the jumps
that return from procedure calls. Previously, it was okay to redirect
returns from several calls so that all go to the same label, since
the live variable information associated with the labels could be
merged. However, we now also associate line numbers with calls, and
these cannot be usefully merged.
compiler/optimize.m:
Pass the information required by jumpopt to it.
doc/user_guide.texi:
Document that you can now break at line numbers.
Document the new "context" command, and the -d or --detailed option
of the stack command and the commands that set ancestor levels.
runtime/mercury_stack_layout.h:
Extend the module layout structure definition with the new tables.
Remove the conditional facility for including label numbers in label
layout structures. It hasn't been used in a long time, and neither
Tyson or me expect to use it to debug either gc or the debugger itself,
so it has no uses left; the line numbers have superseded it.
runtime/mercury_stack_trace.[ch]:
Extend the code to print stack traces to also optionally print
contexts.
Add some utility predicates currently used by the debugger that could
also be use for debugging gc or for more detailed stack traces.
trace/mercury_trace_internal.c:
Implement the "break <context>" command, the "context" command, and
the -d or --detailed option of the stack command and the commands
that set ancestor levels.
Conditionally define a conditionally used variable.
trace/mercury_trace_external.c:
Minor changes to keep up with the changes to stack traces.
Delete an unused variable.
trace/mercury_trace_spy.[ch]:
Check for breakpoints on contexts.
trace/mercury_trace_tables.[ch]:
Add functions to search the RTTI data structures for labels
corresponding to a given context.
trace/mercury_trace_vars.[ch]:
Remember the context of the current environment.
tests/debugger/queen.{inp,exp}:
Test the new capabilities of the debugger.
tests/debugger/*.{inp,exp}:
Update the expected output of the debugger to account for contexts.
In some cases, modify the input script to put contexts where they don't
overflow lines.
|
||
|
|
c460b3eec3 |
Fix a bug: MR_stack_trace_bottom and MR_nondet_stack_trace_bottom
Estimated hours taken: 0.25 runtime/mercury_stack_trace.h: runtime/mercury_stack_trace.c: Fix a bug: MR_stack_trace_bottom and MR_nondet_stack_trace_bottom were being _defined_ in the header file. I changed it so that they were only _declared_ in the header file, and defined in the .c file. |
||
|
|
cc61b711cd |
Moves the definition of MR_dump_stack_record_print() and MR_print_proc_id()
Estimated hours taken: 3 Moves the definition of MR_dump_stack_record_print() and MR_print_proc_id() from trace/ to runtime/ to be able to call MR_dump_stack_record_print() from MR_dump_stack(). Indeed we can not pass down *MR_dump_stack_record_print() as a parameter of MR_dump_stack() since MR_dump_stack() is called from the library and we have to repect the invariant "trace -> library -> runtime". runtime/mercury_stack_trace.c: Add the missing argument of MR_dump_stack_from_layout() in the body of MR_dump_stack(). runtime/mercury_stack_trace.[ch]: trace/mercury_trace_internal.c: trace/mercury_trace_tables.[ch]: Move the definition of MR_dump_stack_record_print() from mercury_trace_internal.c to mercury_stack_trace.c and MR_print_proc_id() from mercury_trace_tables.c to mercury_stack_trace.c runtime/mercury_stack_trace.[ch]: trace/mercury_trace.[ch]: Move the definition of MR_detism_names[] from mercury_trace.c to mercury_stack_trace.c. |
||
|
|
f31b6bf9ed |
Fix some warnings about incompatible pointer types.
Estimated hours taken: 0.2 runtime/mercury_stack_trace.h: runtime/mercury_stack_trace.c: Fix some warnings about incompatible pointer types. |
||
|
|
9760975d5e |
This change implement stack dump commands for the external debugger.
Estimated hours taken: 7 This change implement stack dump commands for the external debugger. The MR_dump_stack_record_print() defined in runtime/mercury_stack_trace.c is the function that prints the contents of the stack. We move the definition of this function to mercury_trace_internal.c and we pass down that function as a parameter of MR_dump_stack_from_layout(). The rational for this change is that we can then define a new MR_dump_stack_record_print_to_socket() in mercury_trace_external.c that prints the data to the socket as a Prolog term and pass down the address of that new function to MR_dump_stack_from_layout(). browser/debugger_interface.m: Add three new kinds of requests: stack, nondet_stack and stack_regs. trace/mercury_trace_external.c: Define new MR_dump_stack_record_print_to_socket() and MR_print_proc_id_to_socket() that sends data to the socket as Prolog terms. Add support for stack, nondet stack and stack_regs requests. runtime/mercury_stack_trace.[ch] trace/mercury_trace.[ch]: trace/mercury_trace_internal.[ch]: Move the definition of MR_dump_stack_record_print(), from mercury_stack_trace.c to mercury_trace_internal.c. Add MR_dump_stack_record_print() as an argument of all the functions that need it in mercury_stack_trace.c. Move the definition of detism_names[] from mercury_stack_trace.c to mercury_trace.c. This function is needed by both versions of MR_dump_stack_record_print(). Rename detism_names[] by MR_detism_names[]. runtime/mercury_stack_trace.[ch] trace/mercury_trace_tables.[ch]: Move the definition of MR_print_proc_id() and MR_print_proc_id_for_debugger() from mercury_stack_trace.c to mercury_trace_tables.c since MR_print_proc_id() is called in that module. Include mercury_trace.h since we now make use of detism_names[] there. |
||
|
|
9d0fd6601a |
Add support to mdb for doing the debugger I/O in a different
Estimated hours taken: 4 Add support to mdb for doing the debugger I/O in a different window to the I/O of the program being debugged. (TODO: I/O from the browser still goes to the standard I/O streams rather than the debugger I/O streams. I will commit that soon as a separate change.) runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: Add new runtime options for specifying filenames for the mdb I/O streams. doc/user_guide.texi: Document the new options. trace/mercury_trace_internal.c: Add three new variables holding the mdb I/O streams. Initialise them based on the option settings. Change the code so that all I/O goes through these streams. trace/mercury_trace_tables.c: trace/mercury_trace_tables.h: Pass a `void *' parameter through MR_process_matching_procedures() to the function it calls. This is needed by mercury_trace_internal.c to pass `MR_mdb_in' down to MR_print_proc_id_for_debugger(). runtime/mercury_stack_trace.c: runtime/mercury_stack_trace.h: Add a `FILE *' parameter to MR_print_proc_id_for_debugger(). tests/debugger/Mmakefile: When creating the `.out' files, redirect stderr as well as stdout, since debugger error messages now go to stderr rather than stdout. |
||
|
|
9aee4beb06 |
Provide feedback for the "up", "down" and "level" commands in the debugger,
Estimated hours taken: 4
Provide feedback for the "up", "down" and "level" commands in the debugger,
in the form of a line from an enhanced stack dump.
runtime/mercury_stack_layout.h:
Fix the documentation of the call event number slot.
runtime/mercury_stack_trace.[ch]:
Generalize the stack dump routines, to make them capable of printing
the call event number, call sequence number and call depth slots
of calls to traced procedures.
trace/mercury_trace_internal.c:
Add a new option, -d or --detailed, to the stack command, which
prints the call event number, call sequence number and call depth slots
of every ancestor procedure that is execution traced.
When changing levels, provide feedback by identifying the call
to which the level is now set. The feedback is the detailed stack
trace line for that call.
When changing levels, check that we have exec trace info for the call,
not just stack trace info.
Fix an old bug: tables of long options should be and now are
terminated by a NULL row.
doc/user_guide.texi:
Document the new option of the stack command.
Fix the documentation of the errors in the level change commands.
tests/debugger/queens.{inp,exp}:
Test the new functionality of the stack command, and update the
expected output.
|
||
|
|
fbd55b8d7c |
Fix the code in the runtime so that `mmake check_headers' succeeds.
Estimated hours taken: 3
Fix the code in the runtime so that `mmake check_headers' succeeds.
runtime/*.h:
Add #include statements to make all the header files
self-contained.
runtime/mercury_table.h:
runtime/mercury_table.c:
Delete these empty files.
For some reason zs left these files as empty instead of deleting
them when he renamed the module as mercury_hash_table.{h,c}.
runtime/mercury_table_builtins.h:
runtime/mercury_table_enum.h:
runtime/mercury_table_any.h:
runtime/mercury_table_type_info.h:
runtime/mercury_table_builtins.c:
runtime/mercury_table_enum.c:
runtime/mercury_table_any.c:
runtime/mercury_table_type_info.c:
runtime/mercury_tabling.h:
runtime/mercury_tabling.c:
Avoid a circular dependency problem (mercury_tabling.h
depended on mercury_table_*.h which in turn depended on
mercury_tabling.h) by moving all the tabling code into
a single module mercury_tabling.{h,c}.
The new module is a total of 1100 lines of code,
which is not too large IMHO.
Also improve the documentation a little.
runtime/Mmakefile:
Update the reflect the added and removed files.
Also update the rule for `mmake check_headers' so that
it can make use of parallelism in parallel makes.
And make a start towards enforcing namespace cleanliness --
I've added code to check it, but not to enforce it.
|
||
|
|
426ce95ad0 |
Fix a spelling error in a comment.
Estimated hours taken: 0.05 runtime/mercury_stack_trace.h: Fix a spelling error in a comment. |
||
|
|
8a0ceb49aa |
This checkin has several major purposes, set out in the sections below,
Estimated hours taken: 240
This checkin has several major purposes, set out in the sections below,
all connected with the implementation of the new debugger command set.
DOCUMENT NEW DEBUG COMMAND SET
doc/user_guide.texi:
Add a new section on the debugger. The description of the commands
is complete, but some of the background sections, and the section
about how to build debuggable executables, are not yet done.
Update the documentation of the tracing options.
doc/generate_mdb_doc:
A new shell script that automatically converts some of the new
sections of the user guide into the online documentation of the
debugger.
doc/mdb_categories:
The fixed initial part of the online documentation.
doc/Mmakefile:
Add rules for creating mdb_doc, the file that is the online
documentation of the debugger, and for installing it together
with mdbrc.
Mmake.common.in:
Define INSTALL_DOC_DIR for doc/Mmakefile.
scripts/mdbrc.in:
A debugger command script that reads in the online documentation
and then defines some standard aliases.
configure.in:
Define the variable that scripts/mdb.in and scripts/mdbrc.in use
to find the right files, and get configure to perform the
substitutions.
configure.in:
scripts/mdb:
scripts/mdb.in:
Replace mdb with mdb.in. Mdb is now created during configuration
from mdb.in, filling in the name of the file that contains the default
debugger initialization commands.
util/info_to_mdb.c:
A program that does most of the work involved in automatically
converting user guide sections into online documentation.
(This couldn't easily be written in sh, because sh's read
command has no notion of pushback.)
util/Mmakefile:
Add info_to_mdb to the list of targets.
tools/bootcheck:
Make sure that the tests in tests/debugger are executed with an
initialization setup that is equivalent to what users will see
by default.
REORGANIZE TRACING OPTIONS
compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
compiler/trace.m:
Reorganize the handling of trace levels around the new options
--trace-internal, --trace-redo, and --trace-return.
compiler/*.m:
Use the new ways of getting at trace levels.
tests/hard_coded/typeclasses/Mmakefile:
s/--trace all/--trace deep/
SUPPORT RETRY
compiler/trace.m:
After every call to MR_trace(), emit code that checks whether it
should jump away, and if yes, performs the jump. This is used to
implement retry. (The debugger cannot execute the jump itself
because it is in the wrong C stack frame.)
compiler/llds.m:
compiler/continuation_info.m:
compiler/stack_layout.m:
Modify the data structures that record information about live
value at program points, to record the identity of each variable.
This is necessary for the implementation of the restart command,
since we do not want to confuse two distinct variables just because
they have the same name. For example, a variable whose name is X
and number is 5 is now recorded in the name array as "5:X".
Clean up the data structure a bit, so that we don't have to store
dummy names for values that are not variables.
compiler/*.m:
Minor changes to conform to the data structure changes.
runtime/mercury_stack_layout.h:
Redefine an existing macro to strip away the initial number: prefix
from the "name" of a variable (keeping its original function on
changed data), and add a new one to access the raw unstripped data.
runtime/mercury_init.h:
runtime/mercury_wrapper.h:
Update the prototype of MR_trace_{fake,real}, and the type of the
global that points to them.
runtime/mercury_layout_util.h:
Add an extra function, MR_get_register_number, for use by retry.
USE FIXED STACK SLOTS FOR TRACE INFO
compiler/code_gen.m:
compiler/code_info.m:
compiler/live_vars.m:
compiler/trace.m:
If execution tracing is enabled, reserve the first few stack slots
to hold the event number of the call event, the call number, the
call depth, the redo layout structure address (if generating redo
events) and the from_full flag at the time of call (if we are doing
shallow tracing). By allocating the first four of these to fixed stack
slots, the debugger knows where to look for them without having
to be told. It finds out the location of the fifth, if needed,
from a new slot in the proc layout structure. (It is not possible
to allocate all five to fixed stack slots without wasting stack space
in some cases.)
compiler/trace.m:
Remove from the call to MR_trace the parameters that are now in fixed
stack slots, since MR_trace can now look them up itself.
compiler/continuation_info.m:
compiler/stack_layout.m:
Add an extra field to the proc_layout_info. If the module is shallow
traced, this field says which stack slot holds the saved value of
MR_from_full. If it is not shallow traced, this field says that
there is no such stack slot.
runtime/mercury_stack_layout.h:
Add macros for accessing the fixed stack slots holding the event
number of the call event, the call number, the call depth, and,
at a redo event, the redo layout structure address.
Support the new field in proc layouts that gives the location of the
from-full flag (if any).
runtime/mercury_trace_base.[ch]:
trace/mercury_trace.[ch]:
Remove the call number and call depth arguments from MR_trace
and its avatars, since this info is now in fixed stack slots
in every procedure that can call MR_trace. This should reduce
the size of the executable significantly, since there are lots
of calls to MR_trace.
runtime/mercury_init.h:
runtime/mercury_wrapper.h:
Update the prototype of MR_trace_{fake,real}, and the type of the
global that points to them.
START NUMBERING FRAMEVARS FROM ONE
compiler/code_info.m:
compiler/live_vars.m:
compiler/llds_out.m:
compiler/trace.m:
Start numbering framevars from 1 internally to the compiler;
the runtime already starts from 1. This simplifies several tasks.
ADD REDO EVENTS
compiler/trace.m:
compiler/code_gen.m:
Before the code that executes "succeed()", emit code to push a
a temp nondet frame whose redoip points to a label in the runtime
that calls MR_trace for a REDO event and then fails, provided
--trace-redo is set.
compiler/llds.m:
Add a new code address constant, do_trace_redo_fail, which stands
for the address in the trace system to which calls MR_trace for
the redo event and then fails.
compiler/trace.m:
compiler/llds_out.m:
Provided we are doing redo tracing, fill in the slot that holds
the layout information for the REDO event.
compiler/*.m:
Minor changes to conform to handle the new code address constant.
browser/debugger_interface.m:
Add redo to trace_port_type.
runtime/mercury_trace_base.[ch]:
Add a C module containing the code that calls MR_trace for REDO
events.
ENSURE THAT INPUT ARGUMENTS ARE ALWAYS VISIBLE
compiler/trace.m:
When generating the set of live variables at internal ports,
the variables that are in the pre-death set of the goal into which
we are entering may not be available. However, the variables in the
pre-death set that are also in the resume vars set will be available,
so now include info about them in the layout structure for the event.
Since with tracing the non-clobbered input args are in all resume vars
sets, this ensures that these input args will be available from all
internal events.
compiler/code_info.m:
Export a previously internal predicate (current_resume_point_vars)
to make this possible.
BUG FIX: WANT RETURN LAYOUTS
compiler/globals.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/mercury_compile.m:
Add a new pred globals__want_return_layouts, which says whether the
compiler should generate layout structures for call returns. This pred
centralizes the several previous copies of the test. One of those
copies (the one in call_gen) was faulty, leading to a bug: in the
presence of execution tracing but the absence of accurate gc,
information about the variables that are live at the call return
wasn't being gathered properly.
BUG FIX: #include mercury_trace_base.h
compiler/llds_out.m:
#include mercury_trace_base.h, not mercury_trace.h, since now
mercury_trace_base.h defines everything directly accessible from
modules compiled with tracing.
RECAST MERCURY_TRACE_UTIL AS MERCURY_LAYOUT_UTIL
runtime/mercury_trace_util.[ch]:
runtime/mercury_layout_util.[ch]:
Rename this module from trace_util to layout_util, since it is also
used by the native garbage collector. Remove "trace" from the names
of functions.
Get rid of the global variable MR_saved_regs, and instead thread
a pointer to this data structure through the relevant functions
as an extra argument.
Add a lot more documentation in the header file.
runtime/Mmakefile:
Reflect the module rename.
runtime/*.c:
Refer to the new module.
DELETE EASY-TO-MISUSE MACROS
runtime/mercury_stacks.h:
Delete the based_framevar and based_detstackvar macros, since their
continued use can lead to off-by-one errors, and the saved_framevar
and saved_detstackvar macros, since they are no longer used.
runtime/*.c
Update any references to any macros removed from mercury_stacks.h.
MISC RUNTIME CHANGES
runtime/mercury_trace_base.[ch]:
trace/mercury_trace*.[ch]:
Make typedef'd names conform to the naming convention.
Make MR_trace_call_{seqno,depth} consistently Unsigned, rather than
sometimes Word and sometimes Unsigned.
FIX BUG: MAKE THE DEBUGGER PRINT TO STDOUT, NOT THE CURRENT STREAM
library/io.m:
Export to C code the predicates that return the identities and types
of stdin, stdout and stderr, as well as io__print/[34].
library/std_util.m:
Export to C code a predicate that returns the type_info for the
type stdutil:type_info. This type_info is required if C code
wants to invoke make_permanent on any type_info structure,
as the debugger does.
runtime/mercury_init.h:
Add extern declarations for the C functions now exported from io.m.
runtime/mercury_wrapper.[ch]:
Add new global variables to hold the addresses of these C functions.
runtime/mercury_layout_util.c:
Use indirect calls through these global variables to print Mercury
values, instead of lower-level code.
util/mkinit.c:
Assign the addresses of the functions exported from io.m to the
global variables defined in mercury_wrapper.h.
BUG FIX: STACK TRACE FUNCTIONS DEPEND ON THE LABEL TABLE
runtime/mercury_stack_trace.c:
On entry to any of the functions exported from this module,
ensure that the label table is loaded by calling do_init_modules.
Without a filled-in label table, the stack trace will not be able to
find any stack layout info.
BUG FIX: REMOVE BROWSER/*.C
configure.in:
When removing .c files generated by the C compiler, remove those
in the browser directory as well as the compiler, library and
profiler directories.
IMPLEMENT NEW DEBUGGER COMMAND SET
runtime/mercury_stack_trace.[ch]:
Factor out the code that prints the id of a procedure into a function
of its own, so that it can also be used from the debugger, ensuring
appearance commonality.
Add more documentation in the header file.
trace/mercury_trace_internal.c:
Implement the proposed command set. Command names are now words,
and several commands now have options allowing the user to override
the default print level or strictness of the command, or the
invocation conditions or action of a break point. Allows control
over command echoing and the scrolling of sequences of event reports.
Supports aliases, command file sourcing etc. Implements the retry
command, using the info in the fixed stack slots.
trace/mercury_trace.[ch]:
Extend the trace controls to support the new functionalities
required by the new debugger language, which are print levels,
variable-strictness commands, a more flexible finish command,
and the retry command.
Pass the command structure to MR_trace_event_report, since
the user can now forcibly terminate the scrolling of reports.
trace/mercury_trace_alias.[ch]:
New module to manage aliases for the debugger.
trace/mercury_trace_help.[ch]:
New module to interface to browser/help.m.
trace/mercury_trace_spy.[ch]:
New module to manage break points. The test of whether an event
matches a break point is now much more efficient than before.
The new module also allows several breakpoints with different
actions and different invocation conditions (e.g. all ports,
entry port, interface ports or specific (possibly internal) port)
to be defined on the same procedure.
trace/mercury_trace_tables.[ch]:
New module to manage a table of the debuggable modules, in which
each such module is linked to the list of the layouts of all the
procedures defined in that module. This information allows the
debugger to turn the name of a predicate/function (possibly together
with its arity and mode number) into the procedure layout structure
required by the spy point module. Eventually it may also be useful
in supplying lists of identifiers for command line completion.
Modules for which no stack layout information is available will
not be included in the table, since do_init_modules will not
register any labels for them in the label table.
trace/Mmakefile:
Mention the new files.
runtime/mercury_array_macros.h:
A new file holding macros that can be useful in more than one module.
runtime/Mmakefile:
Mention the new file.
runtime/mercury_conf.h.in:
Mention a new configuration macro, MR_CANNOT_USE_STRUCTURE_ASSIGNMENT,
used by runtime/mercury_array_macros.h.
configure.in:
Find out whether we need to define MR_CANNOT_USE_STRUCTURE_ASSIGNMENT.
ADD TRACE DEPTH HISTOGRAMS
runtime/mercury_conf_param.h:
Document MR_TRACE_HISTOGRAM.
runtime/mercury_trace_base.[ch]:
Define the data structures for the histogram, and print the histogram
when a traced program exits if MR_TRACE_HISTOGRAM is set.
trace/mercury_trace.[ch]:
If MR_TRACE_HISTOGRAM is defined, record a count of the number of
events at each depth. This information can help us evaluate space-time
tradeoffs.
FACTOR OUT SHELL CODE HANDLING GRADE IMPLICATIONS
scripts/final_grade_options.sh-subr:
A new file to contain any code that implements implications between
grade flags; currently implements the implication debug -> use trail.
scripts/mgnuc.in:
scripts/ml.in:
Replace the code that is now in final_grade_options.sh-subr with
an inclusion of final_grade_options.sh-subr.
configure.in:
Handle final_grade_options.sh-subr as {init,parse}_grade_options.sh-subr
are handled.
SIMPLIFY THE MAINTAINANCE OF CONSISTENCY BETWEEN DEBUGGER CODE AND DOCUMENTATION
doc/Mmakefile:
Add rules for creating mdb_command_list, a C code fragment
that can included manually in trace/mercury_trace_internal.c
to supply the list of valid commands, and mdb_command_test.inp,
which is a list of invalid invocations of debugger commands,
which tests whether the help message for such invocations
can be located as expected.
doc/generate_mdb_command_list:
doc/generate_mdb_command_test:
Awk scripts to create mdb_command_list and mdb_command_test.inp
respectively from mdb_doc.
tools/bootcheck:
Copy mdb_command_test.inp from doc to tests/debugger.
tests/debugger/Mmakefile:
Add a new test that checks whether we get an internal error, unable
to locate the right help node, for each invalid command invocation in
mdb_command_test.inp.
UPDATE TEST CASES
tests/debugger/Mmakefile:
Reenable queens. Conform to the new set of options.
tests/debugger/*.inp:
tests/debugger/*.exp:
Update the inputs and expected outputs of the debugger test cases
to use the new command set and output formats.
|
||
|
|
376f2c69af |
An initial implementation of the accurate garbage collector.
Estimated hours taken: 90 An initial implementation of the accurate garbage collector. WORK_IN_PROGRESS: Add an entry for the accurate garbage collector. library/builtin.m: library/mercury_builtin.m: library/std_util.m: runtime/mercury_tabling.h: Deep copy terms using the address of the value instead of just the value. library/io.m: Initialize the garbage collector's rootset with the globals. runtime/Mmakefile: Add new files to the Mmakefile. runtime/mercury_accurate_gc.h: runtime/mercury_accurate_gc.c: The new garbage collector. runtime/mercury_agc_debug.c: runtime/mercury_agc_debug.h: Debugging utilities for the new garbage collector. runtime/mercury_deep_copy.c: runtime/mercury_deep_copy.h: runtime/mercury_deep_copy_body.h: Put the deep copy code in mercury_deep_copy_body.h, and #include it with appropriate #defines in order to get a variant for deep_copy(), and one for agc_deep_copy(). agc_deep_copy() forwards pointers as it copies. Also, deep_copy (all variants) have been modified to take a pointer to the data to be copied, because some variants need to be able to modify it. runtime/mercury_engine.c: runtime/mercury_engine.h: Add a second heap_zone which is the to-space of the copying collector. Add a debug_heap_zone, which is used as a scratch heap for debugging. runtime/mercury_label.c: Instead of realloc(entry_table, ....) do entry_table = realloc(entry_table, ....) to avoid horrible bugs. Also, make sure the tables get initialized before looking up an entry label. runtime/mercury_imp.h: Include mercury_debug.h before most of the modules. (mercury_engine.h adds a new MemoryZone only if we are debugging accurate GC). runtime/mercury_memory.c: Setup the debug_memory_zone sizes. Remove an unnecessary prototype. runtime/mercury_memory_handlers.c: Add code to get the program counter and the stack pointer from the signal context. Call MR_schedule_agc() from default_handler() if doing accurate gc. runtime/mercury_memory_zones.c: Setup the hardzone regardless of whether redzones are used. Add some more debugging information. runtime/mercury_regorder.h: runtime/machdeps/alpha_regs.h: runtime/machdeps/i386_regs.h: Add definitions to make the real machine registers name/number for MR_sp available. runtime/mercury_trace_internal.c: runtime/mercury_trace_util.c: runtime/mercury_trace_util.h: Add MR_trace_write_variable(), which writes terms given their value and type_info. runtime/mercury_wrapper.c: runtime/mercury_wrapper.h: Change the size of the heap redzone when doing accurate GC. Use a small heap when debugging agc. runtime/mercury_debug.h: runtime/mercury_conf_param.h: Add new debugging macros and document them. runtime/mercury_type_info.c: Add const to the pointer arguments of MR_make_type_info. |
||
|
|
d1855187e5 |
Implement new methods of handling failures and the end points of branched
Estimated hours taken: 260
Implement new methods of handling failures and the end points of branched
control structures.
compiler/notes/failure.html:
Fix an omission about the handling of resume_is_known in if-then-elses.
(This omission lead to a bug in the implementation.)
Optimize cuts across multi goals when curfr is known to be equal
to maxfr.
Clarify the wording in several places.
compiler/code_info.m:
Completely rewrite the methods for handling failure.
Separate the fields of code_info into three classes: those which
do not change after initialization, those which record state that
depends on where in the HLDS goal we are, and those which contain
persistent data such as label and cell counters.
Rename grab_code_info and slap_code_info as remember_position
and reset_to_position, and add a wrapper around the remembered
code_info to make it harder to make mistakes in its use.
(Only the location-dependent fields of the remembered code_info
are used, but putting only them into a separate data structure would
result in more, not less, memory being allocated.)
Gather the predicates that deal with handling branched control
structures into a submodule.
Reorder the declarations and definitions of access predicates
to conform to the new order of fields.
Reorder the declarations and definitions of the failure handling
submodule to better reflect the separation of higher-level and
lower-level predicates.
compiler/code_gen.m:
Replace code_gen__generate_{det,semi,non}_goal_2 with a single
predicate, since for most HLDS constructs the code here is the same
anyway (the called preds check the code model when needed).
Move classification of the various kinds of unifications to unify_gen,
since that is where it belongs.
Move responsibility for initializing the code generator's trace
info to code_info.
Move the generation of code for negations to ite_gen, since the
handling of negations is a cut-down version of the handling of
negations. This should make the required double maintenance easier,
and more likely to happen.
compiler/disj_gen.m:
compiler/ite_gen.m:
These are the two modules that handle most failures; they have
undergone a significant rewrite. As part of this rewrite, factor
out the remaining common code between model_non and model_{det,semi}
goals.
compiler/unify_gen.m:
Move classification of the various kinds of unifications here from
code_gen. This allows us to keep several previously exported
predicates private.
compiler/call_gen.m:
Factor out some code that was common to ordinary calls, higher order
calls and method calls. Move the common code that checks whether
we are doing tracing to trace.m.
Replace call_gen__generate_{det,semi,nondet}_builtin with a single
predicate.
Delete the commented out call_gen__generate_complicated_unify,
since it will never be needed and in any case suffered from
significant code rot.
compiler/llds.m:
Change the mkframe instruction so that depending on one of its
arguments, it can create either ordinary frames, or the cut-down
frames used by the new failure handling algorithm (they have only
three fixed fields: prevfr, redoip and redofr).
compiler/llds_out.m:
Emit a #define MR_USE_REDOFR before including mercury_imp.h, to
tell the runtime we are using the new failure handling scheme.
This effectively changes the grade of the compiled module.
Emit MR_stackvar and MR_framevar instead of detstackvar and framevar.
This is a step towards cleaning up the name-space, and a step towards
making both start numbering at 0. For the time being, the compiler
internally still starts counting framevars at 0; the code in llds_out.m
adds a +1 offset.
compiler/trace.m:
Change the way trace info is initialized to fit in with the new
requirements of code_info.m.
Move the "are we tracing" check from the callers to the implementation
of trace__prepare_for_call.
compiler/*.m:
Minor changes in accordance with the major ones above.
compiler/options.m:
Introduce a new option, allow_hijacks, which is set to "yes" by
default. It is not used yet, but the idea is that when it is set to no,
the code generator will not generate code that hijacks the nondet
stack frame of another procedure invocation; instead, it will create
a new temporary nondet stack frame. If the current procedure is
model_non, it will have three fields: prevfr, redoip and redofr.
If the current procedure is model_det or model_semi, it will have
a fourth field that is set to the value of MR_sp. The idea is that
the runtime system, which will be able to distinguish between
ordinary frames (whose size is at least 5 words), 3-word and 4-word
temporary frames, will now be able to use the redofr slots of
all three kinds of frames and the fourth slot values of 4-word
temporary frames as the addresses relative to which framevars
and detstackvars respectively ought to be offset in stack layouts.
compiler/handle_options.m:
Turn off allow_hijacks if the gc method is accurate.
runtime/mercury_stacks.h:
Change the definitions for the nondet stack handling macros
to accommodate the new nondet stack handling discipline.
Define a new macro for creating temp nondet frames.
Define MR_based_stackvar and MR_based_framevar (both of which start
numbering slots at 1), and express other references, including
MR_stackvar and MR_framevar and backward compatible definitions of
detstackvar and framevar for hand-written C code, in terms of those
two.
runtime/mercury_stack_trace.[ch]:
Add a new function to print a dump of the fixed elements nondet stack,
for debugging my changes. (The dump does not include variable values.)
runtime/mercury_trace_internal.c:
Add a new undocumented command "D" for dumping the nondet stack
(users should not know about this command, since the output is
intelligible only to implementors).
Add a new command "toggle_echo" that can cause the debugger to echo
all commands. When the input to the debugger is redirected, this
echo causes the output of the session to be much more readable.
runtime/mercury_wrapper.c:
Save the address of the artificial bottom nondet stack frame,
so that the new function in mercury_stack_trace.c can find out
where to stop.
runtime/mercury_engine.c:
runtime/mercury_wrapper.c:
Put MR_STACK_TRACE_THIS_MODULE at the tops of these modules, so that
the labels they define (e.g. do_fail and global_success) are registered
in the label table when their module initialization functions are
called. This is necessary for a meaningful nondet stack dump.
runtime/mercury_grade.h:
Add a new component to the grade string that specifies whether
the code was compiled with the old or the new method of handling
the nondet stack. This is important, because modules compiled
with different nondet stack handling disciplines are not compatible.
This component depends on whether MR_USE_REDOFR is defined or not.
runtime/mercury_imp.h:
If MR_DISABLE_REDOFR is defined, undefine off MR_USE_REDOFR before
including mercury_grade.h. This is to allow people to continue
working on un-updated workspaces after this change is installed;
they should put "EXTRA_CFLAGS = -DMR_DISABLE_REDOFR" into
Mmake.stage.params. (This way their stage1 will use the new method
of handling failure, while their stage2 2&3 will use the old one.)
This change should be undone once all our workspaces have switched
over to the new failure handling method.
tests/hard_coded/cut_test.{m,exp}:
A new test case to tickle the various ways of handling cuts in the
new code generator.
tests/hard_coded/Mmakefile:
Enable the new test case.
|
||
|
|
4ada219856 |
Reorganize the label table to better fit the needs of accurate gc
Estimated hours taken: 25
Reorganize the label table to better fit the needs of accurate gc
and the tracer, and reduce the size of executables.
With these changes, the size of hello world, compiled with static
Mercury libraries but dynamic C libraries, goes from 150+ Kb to
138+ Kb, much of which is beyond our control (e.g. Boehm gc).
runtime/mercury_label.[ch]:
The old label table contained both entry labels and internal labels,
even though they had different kinds of layouts associated with them
(proc layouts and label layouts respectively). The two kinds of labels
have different usage patterns. Internal labels are needed for stack
walking, which requires random access by exact label address. Entry
labels are needed for finding which procedure a program counter is in
for accurate GC, which requires lower-bound inexact search.
The module now has two separate data structures for the two
different kinds of labels. Internal labels are in a hash table,
as before. Entry labels are in an array (resized on demand),
which is sorted for binary search. The entry label array and
its associated functions are present only if they are needed.
runtime/mercury_goto.h:
Call the new functions in mercury_label.c from the
init_{local,label,entry}{,_sl} macros.
runtime/mercury_misc.[ch]
Use the new functions in mercury_label. Fix some software rot,
so that the code now compiles with MR_DEBUG_GOTOS. (It still does not
compile with MR_LOWLEVEL_DEBUG, but the fix for that would conflict
with Tom's planned change to zone handling, so that fix should be
done after Tom is done.)
Note that mercury_misc.c still defines newmem() and oldmem()
although they are declared in mercury_std.h.
runtime/mercury_stack_trace.c:
Use the new functions in mercury_label. As a result, we also need
to make a few more pointers const.
runtime/mercury_table.[ch]:
Add a new traversal predicate to support a new function in
mercury_label.c. (That function is not used yet, but will be soon.)
runtime/mercury_trace.[ch]:
runtime/mercury_trace_base.[ch]:
Split the old mercury_trace module into two. The functions and
variables that will always be linked in (because they are referenced
from modules such as mercury_wrapper which are always needed) are
now in mercury_trace_base; the other functions and variables
stay in mercury_trace. This way, mercury_trace.o will be linked in
only if some module was compiled with execution tracing. Since
mercury_trace.o drags in mercury_trace_internal.o which drags in
everything needed for printing arbitrary terms (which is a lot),
this can be a significant win.
runtime/Mmakefile:
Include the new module in the library.
runtime/mercury_wrapper.c:
runtime/mercury_conf_param.h:
Remove some obsolete MERCURY_OPTIONS options, which would be
difficult to support with the new label table.
Move the #ifdefs around the -P option, so that programs not
compiled with MR_THREAD_SAFE will accept but ignore the option,
instead of aborting with the usage message.
Replace the long usage message for malformed MERCURY_OPTIONS
environment variables with a pointer to the user's guide.
This saves about 1 Kb on every executable.
runtime/mercury_conf_param.h:
Document MR_STACK_TRACE_THIS_MODULE.
util/mkinit.c:
Add a new flag, -i. If this flag is given, include the initialization
code regardless of grade. If it is not given, include the init code
only if the grade requires it.
The -i should be given if you want the executable to support stack
tracing, or uplevel printing in execution tracing, at the cost of
making the executable link in the init functions of all the modules
in the library.
Put the option handling code in alphabetical order.
Fix the wrong default name of the entry point. (It only worked because
c2init was always overriding the default.)
scripts/c2init.in:
Pass through the -i flag to mkinit.
Put the option handling code in alphabetical order.
compiler/mercury_compile.m:
If the trace level specifies any kind of tracing, pass -i to c2init.
tests/debugger/Mmakefile:
Add -i to the c2init flags.
tests/debugger/*
Update the other half the test cases (those which assume a traced
library) to conform to the changes in the debugger interface.
The first half were updated earlier.
doc/user_guide.texi:
In the environment variable section, modify the entry for
MERCURY_OPTIONS to document all the options it makes sense
for non-developers to use.
Slight changes to two other parts of the guide to reduce duplication
with the new material.
|
||
|
|
4ab3f397b1 |
Allow the debugger to print the values of variables in ancestors
Estimated hours taken: 20 Allow the debugger to print the values of variables in ancestors of the current call. This requires knowledge about which named variables are live at call return sites. Providing this information properly required fixing the interaction of execution tracing and accurate garbage collection. compiler/globals.m: Introduce a new trace level, so that there are now four: none, interface, interface_ports (corresponding to the existing three levels) and the new level interface_ports_returns, each of which requires all the information required by lower levels. Make the trace level abstract, since in the future we may want to introduce trace levels for new combinations, e.g. interfaces and returns but not internal ports. Introduce the necessary new predicates. compiler/continuation_info.m: Redefine internal_label_info to allow us to record separate info about the sets of vars needed at (a) internal ports of execution tracing and at (b) call return points for accurate gc or (now) uplevel printing during execution tracing. Neither is a subset of the other, and they need to be treated differently. compiler/mercury_compile.m: Gather information about vars at return labels if the trace level requires uplevel printing capability, even if agc is off. compiler/stack_layout.m: Fix the handling of labels which are needed both by agc and by execution tracing. If information at a return label is needed only by uplevel printing in execution tracing and not by agc, then discard all info about lvals which do not hold named variables or their typeinfos (in fact we keep all typeinfos at the moment). If a label is both the label of a port and a return label, we include in the layout structure the union of the information recorded for the two roles. Sort the var_info vector before using it to generate layout structures in an attempt to make llds_common more effective and to make lists of variables printed by the debugger look better. Record a distinguished value when there is no info about the vars live at a label, rather than (incorrectly) recording that there are no live variables. Before up-level printing, the lie was harmless; now it isn't. Remove the label number from return label layouts, since the tracer isn't expecting it. It used to be included for debugging purposes if the label was for agc, but it is possible for a label to be needed both for agc and for execution tracing. If Tyson finds he needs the label number, it can be easily turned back on for all label layouts. compiler/code_info.m: Conform to the new definition of internal_label_info. Rename an internal pred for clarity. Rename some bool parameter to correctly reflect their new meaning. compiler/*.m: Trivial changes, mostly due to making trace_level an abstract type. runtime/mercury_stack_layout.h: Remove the label number from return label layouts, since the tracer isn't expecting it. runtime/mercury_stack_trace.[ch]: Add a new function that returns the label layout structure at the Nth ancestor return continuation, together with the values of sp and curfr at that point. This required changing MR_stack_walk_step to step from an entry layout only to the return label layout. runtime/mercury_stacks.h: Add macros that let us access detstackvars and framevars based on these synthesized values of sp and curfr. runtime/mercury_trace_util.[ch]: Generalize several functions to allow them to use synthesized (as opposed to saved) values of sp and curfr in looking up values. Retain functions with the original names and signatures that call the new, general versions with the necessary additional parameters. runtime/mercury_trace_internal.c: Add a new command that sets the "ancestor level". For example, "l 2" sets it to 2, which means that the command "v" and "p" will refer to the grandparent of the current call. The ancestor level persists while the debugger is at the current event; after that it is reset to 0. The implementation involves calling the new function in mercury_stack_trace.c and the generalized functions in mercury_trace_util.c. Also add a deliberately undocumented extra command, X, which prints the stack pointers. NEWS: Add a reminder about removing the X command before release. tests/debugger/* Update half the test cases (those which assume a non-debug-grade library) to conform to the changes in the debugger interface. The others will need to be updated later. |
||
|
|
09141817ba |
Fergus's recent change to the handling of some builtins broke the tracing
Estimated hours taken: 20 Fergus's recent change to the handling of some builtins broke the tracing of those builtins. The following changes are a fix for this. compiler/polymorphism.m: Export the predicate that checks whether a predicate is a builtin that lacks the usually necessary typeinfos. Comment out a misleading and in any case not very useful progress message. compiler/liveness.m: Turn off type_info liveness for builtins without typeinfos. Since these builtins establish no gc points and shouldn't be execution traced, this is OK. Make type_info liveness part of live_info, since it can now be incorrect to look up the value of the option. (This may yield a speedup.) compiler/live_vars.m: compiler/store_alloc.m: Pass the pred_id to initial_liveness to liveness.m can do the test. compiler/passes_aux.m: Add a new traversal type that passes along the pred_id. compiler/mercury_compile.m: Turn off execution tracing for the modules builtin.m and private_builtin.m. The latter contains the interface predicates for the builtins without typeinfos. Since the interface predicates also lack the typeinfos, the compiler would get an internal abort if we left execution tracing on. In any case, these two modules contain stuff that users should consider language builtins, which means they should not be execution traced (they can still be stack traced in the right grade). Use the new traversal type for the modules that now need the pred_id. compiler/globals.m: Allow the trace level to be set from outside, in this case mercury_compile.m. The next batch of changes have to do with adding a stack dump command to the debugger. Since debugging is possible even in non-debug grades, this in turn requires allowing stack tracing to work in non-debug grades, on programs in which only some modules are compiled with execution (and hence stack) tracing. compiler/llds_out.m: compiler/mercury_compile.m: runtime/mercury_conf_param.h: Llds_out used to output "#include <mercury_imp.h>" as the first substantive thing in the generated C file. The set of #define parameters in effect when mercury_imp.h is processed determines whether the macros that optionally register stack layouts for label actually do so or not. The values of these parameters are derived from the grade, which means that with this setup it is not possible for a non-debug grade program to register its stack layouts in the label table. The new version of llds_out looks up the option that says whether this module is compiled with execution tracing or not, and if it is, it generates a #define MR_STACK_TRACE_THIS_MODULE *before* the #include of mercury_imp.h. This causes mercury_conf_param.h, included from mercury_imp.h, to define the macros MR_USE_STACK_LAYOUTS and and MR_INSERT_LABELS, which in turn cause stack layouts for labels in this module to be generated and to be inserted into the label table, *without* changing the grade string (this last part is why we do not simply define MR_STACK_TRACE). Use the same mechanism to #include mercury_trace.h when doing execution tracing, since it is simpler than the mechanism we used to use (mercury_compile.m including the #include in a list of C header file fragments). compiler/mercury_compile.m: runtime/mercury_conf_param.h: Split the MR_NEED_INITIALIZATION_CODE macro into two parts. The first, MR_MAY_NEED_INITIALIZATION, now controls whether initialization code makes it into the object file of a module. The second, MR_NEED_INITIALIZATION_AT_START, determines whether the initialization code is called before main/2. When a module is compiled with execution tracing, the macro MR_INSERT_LABELS turns on MR_MAY_NEED_INITIALIZATION but not MR_NEED_INITIALIZATION_AT_START. The debugger will make sure that the initialization code has been called before it tries to do a stack dump (which needs the initialization code to have been executed, because it needs labels to have been put into the label table so that from a return address it can find the layout of the proc to which it belongs). Define MR_NEED_INITIALIZATION_AT_START if PROFILE_TIME is defined, since if PROFILE_TIME is defined mercury_wrapper.c calls init_modules. The fact that MR_NEED_INITIALIZATION_CODE didn't used to be defined when PROFILE_TIME was defined was, I believe, a bug, which was not detected because we do not turn on PROFILE_TIME without also turning on PROFILE_CALLS. runtime/mercury_stack_trace.[ch]: Change the way stack dumps are done, to make it possible to print stack dumps from the debugger and to use trivial run-length encoding on the output (so that 100 consecutive calls to p yield the line "p * 100", rather than 100 lines of "p"). The stack routine now returns an indication of whether the stack dump was fully successful, and if not, a description of the reason why not. This requires knowing when we have found the end of the stack dump, so we provide a global variable, MR_stack_trace_bottom, which mercury_wrapper.c will set to global_success, the address main/2 goes to on success. s/multidet/multi/ runtime/mercury_wrapper.c: Set MR_stack_trace_bottom to the address of globals_success. Use MR_NEED_INITIALIZATION_AT_START to decide whether to call do_init_modules. runtime/mercury_stacks.h: Provide variants of detstackvar(n) and framevar(n) that look up sp and curfr in an array of saved regs, for use by the debugger. runtime/mercury_trace_util.c: Use the new variants of detstackvar(n) and framevar(n). This fixes an old bug on SPARCs. runtime/mercury_trace_internal.c: Completely reorganize the way debugger commands are handled. Centralize reading in command lines, and the breaking up of command lines into words. The command names are the same as they were, but command syntax is now much easier to change. Add a new command "d" to dump as much of the stack as the available information will allow. runtime/mercury_goto.h: Cosmetic changes to avoid the use of two different conditional compilation layout styles. util/mkinit.c: Since we cannot know when we generate the _init.c file whether any modules will be compiled with execution tracing and will thus need stack tracing, we must now include in the generated _init.c file the code to call the initialization functions in all the modules, even if MR_NEED_INITIALIZATION_AT_START is not set, since init_modules can be called later, from the debugger. (We should be able to use the same approach with the accurate collector.) |
||
|
|
baa8904877 |
Fix spelling error in comment.
Estimated hours taken: 0.02 runtime/mercury_stack_trace.h: Fix spelling error in comment. |
||
|
|
f89be73c94 |
Fix stack traces dying in -O-1.
Estimated hours taken: 3 Fix stack traces dying in -O-1. error/1 is usually generated with no stack frame, but in -O-1 it is generated with one (but doesn't need it). error/1 passes MR_dump_stack MR_succip and MR_sp, and MR_dump_stack assumes that MR_succip is for the topmost stack frame, but if error/1 has a stack frame, this is not true. library/require.m: Make sure the caller of MR_dump_stack has no stack frame by using handwritten code. We call the handwritten code from error/1, and so we have the nice side effect that error now appears in the stack dump. runtime/mercury_stack_trace.h: Document that MR_dump_stack assumes the succip is for the topmost stack frame. runtime/mercury_label.h: Fix a comment, layout info is for a label, not a procedure. |
||
|
|
951ed445bf |
Implement nondet stack dumps.
Estimated hours taken: 1 Implement nondet stack dumps. library/require.m: Call MR_dump_stack with MR_curfr. runtime/mercury_stack_trace.c: runtime/mercury_stack_trace.h: Get MR_curfr as input. If we hit a nondet stack frame, handle moving down a frame a little differently. |
||
|
|
f58ee880df |
Add support for stack dumps, do a stack dump from error/1.
Estimated hours taken: 12 Add support for stack dumps, do a stack dump from error/1. compiler/Mmakefile: library/Mmakefile: profiler/Mmakefile: runtime/Mmakefile: Insert EXTRA_MGNUCFLAGS before CFLAGS or EXTRA_CFLAGS becasue mgnuc stops processing its options when it encounters a non-mgnuc option. library/require.m: Call MR_dump_stack if error is called. runtime/Mmakefile: runtime/mercury_imp.h: Add #includes of new files. runtime/mercury_type_info.h: Remove conditional definition of MR_STATIC_CODE_ADDRESSES (moved into mercury_conf.h.in). runtime/mercury_accurate_gc.h: Remove stack_layout stuff, leave this file for accurate GC specific definitions. runtime/mercury_conf.h.in: Add conditional definitions of MR_INSERT_LABELS, MR_USE_STACK_LAYOUTS, MR_NEED_INITIALIZATION_CODE and MR_STATIC_CODE_ADDRESSES, depending on various other options. runtime/mercury_goto.h: Insert labels into label table if MR_INSERT_LABELS is defined, rather than NATIVE_GC. util/mkinit.c: Initialize if MR_NEED_INITIALIZATION_CODE is defined, rather than NATIVE_GC. runtime/mercury_stack_layout.h: All the old stack layout definitions from mercury_accurate_gc.h. Add code for MR_DETISM_DET_CODE_MODEL. runtime/mercury_stack_trace.c: runtime/mercury_stack_trace.h: Implement MR_dump_stack which just provides a dump of the stack as far as possible. Set MR_INSERT_LABELS and MR_USE_STACK_LAYOUTS if MR_STACK_TRACE is set. runtime/mercury_grade.h: Add _strce if stack tracing is enabled in the grade. This might not be a permanent change. runtime/mercury_ho_call.c: Remove unused label declarations. scripts/mgnuc.in: Add --stack-trace and --no-stack-trace options. Consolidate some duplicate code. |