mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 22:35:41 +00:00
fc29b6c0b6922bb81092ecff6e33fb84cf8c2824
88 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
20ea47995f |
Fix crashes when dumping stack traces.
In MR_dump_stack_from_layout_clique two variables could be accessed without being initialised when jumping to the label 'done'. Also, pair calls to MR_malloc/MR_realloc with MR_free instead of free. This is purely cosmetic while MR_free is an alias for free. runtime/mercury_stack_trace.c: As above. |
||
|
|
1962dd6990 |
Avoid a core dump that we used to get when traversing stack frames
Estimated hours taken: 0.5 Branches: main runtime/mercury_stack_trace.c: Avoid a core dump that we used to get when traversing stack frames without debug info, such as the stack frames of hand-written procedures like builtin_catch. |
||
|
|
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.
|
||
|
|
d4bbcda309 |
Move all the frequently occurring layout structures and components of layout
Estimated hours taken: 40 Branches: main Move all the frequently occurring layout structures and components of layout structures into arrays where possible. By replacing N global variables holding individual layout structures or layout structure components with one global variable holding an array of them, we reduce the sizes of the symbol tables stored in object files, which should speed up both the C compiler and the linker. Measured on the modules of the library, mdbcomp and compiler directories compiled in grade asm_fast.gc.debug, this diff reduces the size of the generated C source files by 7.8%, the size of the generated object files by 10.4%, and the number of symbols in the symbol tables of those object files by a whopping 42.8%. (These improvements include, and are not on top of, the improvements in my previous similar diff.) runtime/mercury_stack_layout.h: Each label layout structure has information about the type and location of every variable that is live at that label. We store this information in three arrays: an array of pseudo-typeinfos giving the types of all these variables, and two arrays MR_ShortLvals and MR_LongLvals respectively giving their locations. (Most of the time, the location's encoded form fits into one byte (the MR_ShortLval) but sometimes it needs more bits (this is when we use MR_LongLval)). We used to store these three arrays, whose elements are different types, in a single occurrence-specific common structure, one after the other, with a cumbersome mechanism being required to access them. We now store them as segments of three separate arrays, of pseudo-typeinfos, MR_ShortLvals and MR_LongLvals respectively. This makes access simpler and faster (which will matter more to any accurate garbage collector than it does to the debugger). It also allows more scope for compression, since reusing an existing segment of one of the three arrays is easier than reusing an entire common structure, which would require the equivalent of exact matches on all three arrays. Since most label layout structures that have information about variables can encode the variables' locations using only MR_ShortLvals, create a version of the label layout structure type that omits the field used to record the whereabouts of the long location descriptors. Add macros now generated by the compiler to initialize layout structures. Simplify a one-field struct. runtime/mercury_grade.h: Increment the binary compatibility version number for debuggable executables, since .c and .o files from before and after the change to label layout structures are NOT compatible. runtime/mercury_type_info.h: Fix some binary-compatibility-related bit rot. runtime/mercury_misc.h: Move here the existing macros used by the compiler when generating references to layout arrays, and add new ones. runtime/mercury_goto.h: Delete the macros moved to mercury_misc.h. Conform to the changes in mercury_stack_layout.h. runtime/Mmakefile: Prevent the unnecessary rebuilding of mercury_conf.h. runtime/mercury_accurate_gc.c: runtime/mercury_agc_debug.c: runtime/mercury_layout_util.c: runtime/mercury_stack_trace.c: runtime/mercury_types.h: trace/mercury_trace.c: trace/mercury_trace_vars.c: Conform to the changes in mercury_stack_layout.h. runtime/mercury_wrapper.c: Improve the debug support a bit. runtime/mercury_engine.h: Fix style. compiler/layout.m: Make the change described at the top. Almost all layout structures are now in arrays. The only exceptions are those that occur rarely, and proc layouts, whose names need to be derivable from the name of the procedure itself. Instead of having a single type "layout_data" that can represent different kinds of single global variables (not array slots), have different kinds for different purposes. This makes the code clearer and allows traversals that do not have to skip over inapplicable kinds of layout structures. compiler/layout_out.m: Output the new arrays. compiler/stack_layout.m: Generate the new arrays. Previously, an individual term generated by stack_layout.m could represent several components of a layout structure, with the components separated by layout_out.m. We now do the separation in stack_layout.m itself, adding each component to the array to which it belongs. Instead of passing around a single stack_layout_info structure, pass around several smaller one. This is preferable, since I found out the hard way that including everything in one structure would give the structure 51 fields. Most parts of the module work with only one or two of these structures, which makes their role clearer. Cluster related predicates together. compiler/options.m: doc/user_guide.texi: Add an option that control whether stack_layout.m will attempt to compress the layout arrays that can meaningfully be comressed. compiler/llds.m: Remove the old distinction between a data_addr and a data_name, replacing both types with a single new one: data_id. Since different kinds of data_names were treated differently in many places, the distinction in types (which was intended to allow us to process data_addrs that wrapped data_names differently from other kinds of data_addrs) wasn't buying us anything anymore. The new data_id type allows for the possibility that the code generator wants to generate a reference to an address it does not know yet, because it is a slot in a layout array, and the slot has not been allocated yet. Add the information from which the new layout array structures will be generated to the LLDS. compiler/llds_out.m: Call layout_out.m to output the new layout arrays. Adapt the decl_id type to the replacement of data_addrs by data_ids. Don't both keeping track of the have-vs-have-not-declared status of structures that are always declared at the start. When writing out a data_addr, for some kinds of data_addr, llds_out.m would write out the name of the relevant variable, while for some other kinds, it would write out its address. This diff separates out those those things into separate predicates, each of which behaves consistently. compiler/mercury_compile_llds_back_end.m: Convey the intended contents of the new layout arrays from stack_layout.m to llds_out.m. compiler/continuation_info.m: Add a type required by the way we now generate proc_static structures for deep profiling. compiler/hlds_rtti.m: Add distinguishing prefixes to the field names of the rtti_proc_label type. compiler/code_info.m: compiler/code_util.m: compiler/erl_rtti.m: compiler/exprn_aux.m: compiler/global_data.m: compiler/ll_pseudo_type_info.m: compiler/ml_code_util.m: compiler/opt_debug.m: compiler/proc_gen.m: compiler/prog_rep.m: compiler/rtti_out.m: compiler/unify_gen.m: Conform to the changes above. tests/debugger/declarative/track_through_catch.exp: Expect procedures to be listed in the proper order. tests/EXPECT_FAIL_TESTS.asm_fast.gc.debug: tests/EXPECT_FAIL_TESTS.asm_fast.gc.profdeep: Add these files to ignore expected failues in these grades. |
||
|
|
ee74813099 |
Avoid warnings from gcc 4.3 in the runtime.
runtime/mercury_stack_trace.c: Handle values of type MR_Level in format strings correctly. runtime/mercury_wrapper.c: Check the return value of a call to system(). |
||
|
|
72b6d4aa18 |
Avoid a warning from the C compiler.
runtime/mercury_stack_trace.c: Delete an unused local variable which is shadowed by another one. (It isn't apparent in the source since the declaration of the latter one is only present as the result of a macro expansion.) library/list.m: Unrelated change: fix an out-of-place comma. |
||
|
|
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.
|
||
|
|
122579d906 |
Nondet stack segments didn't work properly using the placeholder frame trick
Branches: main Nondet stack segments didn't work properly using the placeholder frame trick at the base of nondet stack segments. i.e. when we jump to special procedure (MR_pop_nondetstack_segment) stored in the succip slot of the base frame, it should free the top stack segment, set maxfr to the correct value and jump to the real succip. However, we were reading values of maxfr and succip from the *det* stack which is clearly wrong. After fixing that, it still didn't work properly. Nondet execution seems to be too haphazard for the trick to work. MR_pop_nondetstack_segment() can be entered not only when the top stack segment can be deallocated, which complicates things. Instead, switch to a simpler method to deallocate nondet stack frames. When creating a nondet frame, we know that all stack segments above that which `maxfr' points into can be freed. In the common case, `maxfr' *will* point into the top stack segment and that can be checked with just one additional test. After deallocating excess stack segments, the new frame can be created as before. See also Mantis bug #65. runtime/mercury_stacks.h: Make `MR_nondetstack_extend_and_check' check that `maxfr' still lives on the top nondet stack segment. If not, or if a new segment is required, call `MR_nondetstack_segment_extend_slow_path'. runtime/mercury_stacks.c: Rename `MR_new_detstack_segment' to `MR_nondetstack_segment_extend_slow_path'. Make it free excess nondet stack segments. Fix a bug where `MR_NONDET_FIXED_SIZE' was added twice to the number of slots required for a new frame. Delete `MR_pop_nondetstack_segment' which is no longer used. Don't use red zones for new det and nondet stack segments. Add missing parameters to some debugging code. runtime/mercury_stack_trace.c: Delete reference to `MR_pop_nondetstack_segment'. runtime/mercury_memory_zones.c: Add sanity checks for small memory zone sizes, e.g. they may be too small to fit all of the usable zone area, red zone and cache offset. NEWS: Announce stack segment support as it should be stable now. |
||
|
|
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. |
||
|
|
4bf295460a |
Fix up some places in the trace directory where there were (potential)
Estimated hours taken: 5
Branches: main
Fix up some places in the trace directory where there were (potential)
mismatches between the sizes of types used to represent natural numbers.
Much of the existing code in the trace directory assumed that
sizeof(int) == sizeof(MR_Unsigned), which is not true on our 64-bit
machines. Zoltan's recent change to MR_trace_is_natural_number() broke
that assumption in a lot of places. (I committed a workaround for that
yesterday.)
This diff addresses the above problem by changing the types of many of
things that represent natural numbers from int to MR_Unsigned.
This should make the trace code more robust on 64-bit machines and
help avoid a recurrence of problems like the above.
NOTE: this change does not change slot numbers into unsigned values since
they still use negative values as sentinels. I will address slot numbers
in as part of a separate change.
trace/mercury_trace.h:
Add typedefs for MR_Unsigned for several commonly used quantities
within the trace code. For I/O action numbers we just re-use
the type MR_IoActionNum from the runtime, rather than defining
a new typedef here.
trace/mercury_trace_tables.h:
Change the type of the `match_proc_max' and `match_proc_next' fields
of the MR_MatchesInfo structure into MR_Unsigned instead of int.
trace/mercury_trace_cmd_parameter.[ch]:
Change the type of the global variables, MR_scroll_{limit,next}
and MR_num_context_lines into MR_Unsigned instead of int.
trace/mercury_trace_util.[ch]:
Restore Zoltan's change that made the type of the second argument of
MR_trace_is_natural_number() into MR_Unsigned. The places that
caused this to break on 64-bit machines have now been fixed.
Update the documentation of MR_trace_is_natural_number();
Delete MR_trace_is_unsigned() since that now duplicates
MR_trace_is_natural_number().
Add a new function MR_trace_is_nonneg_int() which is similar
to the above functions except that it stores its result in
an int. (This is needed for handling slot numbers which are
still represented using ints.)
trace/mercury_trace_cmd_developer.c:
Refactor some code so that we don't need to use -1 as a sentinel
value.
trace/mercury_trace_cmd_help.c:
Use MR_trace_is_nonneg_int() instead of MR_trace_is_natural_number()
to handle slot numbers.
runtime/mercury_trace_base.[ch]:
Change the type of the first argument of MR_trace_get_action()
from int to MR_IoActionNum.
trace/mercury_trace_alias.c:
trace/mercury_trace_cmd_backward.c:
trace/mercury_trace_cmd_breakpoint.c:
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_cmd_dd.c:
trace/mercury_trace_cmd_exp.c:
trace/mercury_trace_cmd_forward.c:
trace/mercury_stack_trace.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_spy.[ch]:
trace/mercury_trace_vars.[ch]:
Use MR_Unsigned instead of int to represent natural numbers.
|
||
|
|
b61ea9de44 |
Implement a large chunk of the code that was previously missing for .mmos
Estimated hours taken: 20 Branches: main Implement a large chunk of the code that was previously missing for .mmos grades. The system now correctly computes several answers for the tc_minimal test case, before going into an infinite loop (since the code for recognizing the absence of further solutions is not yet there). Significantly improve the infrastructure for debugging such changes. compiler/table_gen.m: Complete the mmos transformation. compiler/proc_gen.m: Handle the special return requirements of mmos generators, which must return not to a caller (since each generator is the root of its own SLD tree), but to a consumer in another SLD tree that is waiting for an answer. compiler/hlds_pred.m: Provide a mechanism whereby table_gen.m can communicate to proc_gen.m the requirement for this special return. compiler/trace_gen.m: When generating events, include the port and the goal path in a comment. This makes the generated C code significantly easier to understand. compiler/layout_out.m: Export a function for trace_gen.m to use. compiler/hlds_goal.m: Change goal_path_to_string to a function to make it easier to use. compiler/*.m: Conform to the change to goal_path_to_string. runtime/mercury_context.[ch]: In .mmos grades, include the current debugger call sequence number, depth, and event number in contexts, to be saved and loaded with the contexts. This allows each context to have its own separate sequence of events. This capability depends not directly on the grade, but on the macro MR_EXEC_TRACE_INFO_IN_CONTEXT. For now, this is defined only in .mmos grades, but in future, it may be useful in other grades as well. runtime/mercury_conf_param.h: Define and document MR_EXEC_TRACE_INFO_IN_CONTEXT. runtime/mercury_mm_own_stacks.[ch]: runtime/mercury_tabling_preds.h: Implement some predicates needed by the own stack transformation. Implement the code for generators returning answers to consumers, and the code for consumers scheduling generators when they need more answers. At the moment, the code for detecting when generators depend on each other is not yet written. Provide better facilities for debugging own stack minimal model grades. Fix a cut-and-paste bug (wrong macro name guarding the handwritten C module). runtime/Mmakefile: Rebuild only what needs to be rebuilt when mercury_tabling_preds.h changes. runtime/mercury_label.[ch]: Add a utility function for returning the name of an arbitrary label (internal or entry). Rename some fields to give them MR_ prefixes. Always define the functions for recording both entry and internal labels, even if they are not called from most modules, since they may be called from a few handwritten modules in the runtime. Rename a function to avoid a clash with the name of a macro, and thus allow the change to mercury_goto.h. runtime/mercury_goto.h: Fix a bug with MR_init_entry_an. This macro was supposed to always insert the entry label that is its argument into the entry table, but instead of calling the function it was meant to call, it called a macro that could be (and usually way) defined to expand to nothing. The fix is to call the function a different name than the macro, and to call the function, not the macro. runtime/mercury_wrapper.c: In own stack minimal model grades, create a main context separate from the current context, since the current context may be needed to hold a generator's state. Make MR_eng_this_context point to this context. Register all labels in the debugging variants of minimal model grades. runtime/mercury_accurate_gc.c: runtime/mercury_agc_debug.c: runtime/mercury_debug.c: library/exception.m: Conform to the change to runtime/mercury_label.h. runtime/mercury_stack_trace.c: Conform to the change to runtime/mercury_label.h. Document the link to trace/mercury_trace_internal.c. trace/mercury_trace.[ch]: trace/mercury_trace_cmd_forward.c: Split the GOTO command into two: STEP and GOTO. STEP always stops at the next event (without any test), even if it is in a different context (and possibly with a lower event number than the immediately previous event, since the event numbers in different contexts are not related). As before, GOTO always goes to the specified event number, but in .dmmos grades it can now be told that this event number should be matched only in a specified context. The specification is done by an extra argument specifying the short name of the context's generator; the ansence of such an argument means the main context. trace/mercury_trace_cmd_internal.c: In own stack grades, when the current context is that of a generator, print the subgoal the generator is working on before the event number, call depth, call sequence number and the rest of the event report. Document the link to runtime/mercury_stack_trace.c, which has similar code. trace/mercury_trace_cmd_external.c: trace/mercury_trace_cmd_declararive.c: Use the STEP command where GOTO was used for this simpler job, since this is (very slightly) faster. trace/mercury_trace_cmd_developer.c: Fix some bugs with handling own stack tables. doc/user_guide.texi: Document the new functionality of the goto mdb command. The documentation is commented out, since .mmos grades are for developers only at the moment. tools/lmc.in: Turn off C optimizations when C debugging is enabled. For some reason, the default value of --cflags-for-debug does not include -O0. |
||
|
|
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). |
||
|
|
ecf1ee3117 |
Add a mechanism for growing the stacks on demand by adding new segments
Estimated hours taken: 20 Branches: main Add a mechanism for growing the stacks on demand by adding new segments to them. You can ask for the new mechanism via a new grade component, stseg (short for "stack segments"). The mechanism works by adding a test to each increment of a stack pointer (sp or maxfr). If the test indicates that we are about to run out of stack, we allocate a new stack segment, allocate a placeholder frame on the new segment, and then allocate the frame we wanted in the first place on top of the placeholder. We also override succip to make it point code that will (1) release the new segment when the newly created stack frame returns, and then (2) go to the place indicated by the original, overridden succip. For leaf procedures on the det stack, we optimize away the check of the stack pointer. We can do this because we reserve some space on each stack for the use of such stack frames. My intention is that doc/user_guide.texi and NEWS will be updated once we have used the feature ourselves for a while and it seems to be stable. runtime/mercury_grade.h: Add the new grade component. runtime/mercury_conf_param.h: Document the new grade component, and the option used to debug stack segments. runtime/mercury_context.[ch]: Add new fields to contexts to hold the list of previous segments of the det and nondet stacks. runtime/mercury_memory_zones.[ch]: Include a threshold in all zones, for use in stack segments. Set it when a zone is allocated. Restore the previous #ifdef'd out function MR_unget_zone, for use when freeing stack segments execution has fallen out of. runtime/mercury_debug.[ch]: When printing the offsets of pointers into the det and nondet stacks, print the number of the segment the pointer points into (unless it is the first, in which case we suppress this in the interest of brevity and simplicity). Make all the functions in this module take a FILE * as an input argument; don't print to stdout by default. runtime/mercury_stacks.[ch]: Modify the macros that allocate stack frames to invoke the code for adding new stack segments when we are about to run out of stack. Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. Conform to the changes in mercury_debug.c. runtime/mercury_stack_trace.c: When traversing the stack, step over the placeholder stack frames at the bottoms of stack segments. Conform to the changes in mercury_debug.c. runtime/mercury_wrapper.[ch]: Make the default stack size small in grades that support stack segments. Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. Conform to the changes in mercury_debug.c. runtime/mercury_memory.c: Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. runtime/mercury_engine.[ch]: runtime/mercury_overflow.h: Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. Convert these files to four-space indentation. runtime/mercury_minimal_model.c: trace/mercury_trace.c: trace/mercury_trace_util.c: Conform to the changes in mercury_debug.c. compiler/options.m: Add the new grade option for stack segments. compiler/compile_target_code.m: compiler/handle_options.m: Add the new grade component, and handle its exclusions with other grade components and optimizations. compiler/llds.m: Extend the incr_sp instruction to record whether the stack frame is for a leaf procedure. compiler/llds_out.m: Output the extended incr_sp instruction. compiler/proc_gen.m: Fill in the extra slot in incr_sp instructions. compiler/goal_util.m: Provide a predicate for testing whether a procedure body is a leaf. compiler/delay_slot.m: compiler/dupelim.m: compiler/dupproc.m: compiler/exprn_aux.m: compiler/frameopt.m: compiler/global_data.m: compiler/jumpopt.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/peephole.m: compiler/reassign.m: compiler/use_local_vars.m: Conform to the change in llds.m. scripts/canonicate_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: scripts/final_grade_options.sh-subr: scripts/mgnuc.in: Handle the new grade component. Convert parse_grade_options.sh-subr to four-space indentation. Mmake.workspace: Fix an old bug that prevented bootcheck from working in the new grade: when computing the gc grade, use the workspace's version of ml (which in this case understands the new grade components), rather than the installed ml (which does not). (This was a devil to track down, because neither make --debug nor strace on make revealed how the installed ml was being invoked, and there was no explicit invocation in the Makefile either; the error message appeared to come out of thin air just before the completion of the stage 2 library. It turned out the invocation happened implicitly, as a result of expanding a make variable.) |
||
|
|
9eed887d33 |
This diff is the second step in implementing trace events.
Estimated hours taken: 24 Branches: main This diff is the second step in implementing trace events. It modifies label layouts to include room for solver-event-specific information, and modifies the compiler to generate this information. Modifications to the debugger to use this information, user-level documentation and test cases will come later. runtime/mercury_stack_layout.h: Modify label layouts to allow them to hold information about solver events. Modify the macros creating label layouts to include a null pointer as the value of the label layout's solver event field. For each such macro, add a version that puts a pointer to the label's solver event structure in that field. Modify the definition of the MR_Long_Lval type to allow the representation of constants, since without this capability solver events would often need to be preceded by code to put constant values (e.g. solver ids) into lvals. To make it easier to locate all the places where MR_Long_Lvals are used (which need to be updated), change the type MR_Long_Lval from a synonym for an int to a structure containing an int. runtime/mercury_types.h: Add the typedefs now required for mercury_stack_layout.h. runtime/mercury_goto.h: Add a macro needed by mercury_stack_layout.h. runtime/mercury_grade.h: Change the binary compatibility version number for debug grades, due to the change to label layouts. runtime/mercury_layout_util.c: Update the functions interpreting MR_Long_Lvals to conform to the change in mercury_stack_layout.h. runtime/mercury_deep_profiling_hand.h: Fix a bug, possibly the bug preventing us from bootchecking in deep profiling grades: stack slot numbers of ProcStatic structures are supposed to be plain integers, not MR_Long_Lvals. runtime/mercury_stack_trace.c: library/exception.m: trace/mercury_trace.c: Conform the change in MR_Long_Lval. runtime/mercury_trace_base.[ch]: Add a new port: the solver event port. Add a macro and a function for solver events: MR_SOLVER_EVENT and MR_solver_trace. For now, they do the same thing as MR_EVENT and MR_trace, but in future, they can do something else (e.g. generate information for a visualization tool). mdbcomp/prim_data.m: Add a new port: the solver event port. Rename all ports to eliminate clashes with language keywords such as "call". mdbcmp/trace_counts.m: browser/declarative_execution.m: slice/mcov.m: compiler/tupling.m: Conform to the change in port names, and to the addition of the new port. compiler/trace_params.m: Conform to the change in port names, and to the addition of the new port. Rename some function symbols to avoid some ambiguities. trace/mercury_trace_declarative.c: Ignore the solver port when building the annotated trace, since it doesn't fit into it. compiler/prog_event.m: Extend the representation of events to include names for the event attributes. compiler/call_gen.m: Implement event goals. The implementation consists of a call to MR_SOLVER_EVENT with a layout structure whose solver event field points to a solver event structure giving the event goal's arguments. Rename some function symbols to avoid some ambiguities. compiler/trace_gen.m: Add a predicate for generating solver events. Conform to the change in port names. Rename some function symbols to avoid some ambiguities. compiler/code_info.m: When recording trace layout information for a label, take an extra argument describing the label layout's associated solver event, if any. compiler/continuation_info.m: Extend the first representation of label layouts to include room for solver events. compiler/stack_layout.m: Convert the representation of solver events in continuation_info.m's data structure to the data structure required by layout_out.m. Conform to the changes in MR_Long_Lvals. compiler/layout.m: Extend the compiler's internal representation of the contents of label layout structures to accommodate the optional solver event field. compiler/layout_out.m: Generate the extended label layout structures, using the new macros in mercury_stack_layout.h if necessary. Conform to the change in the MR_Long_Lval type. Conform to the change in port names. Rename some function symbols to avoid some ambiguities. compiler/global_data.m: Modify rval_type_as_arg to require only the value of the relevant option, not a package of such options. This is for the new code in stack_layout.m. compiler/var_locn.m: Conform to the change in global_data.m. compiler/llds_out.m: Conform to the change in continuation_info.m. Delete this module's unused definition of rval_type_as_arg. compiler/opt_debug.m: Conform to the change in continuation_info.m. |
||
|
|
c708b19d20 |
Minor formatting fixes.
Estimated hours taken: 0.1 Branches: main runtime/mercury_stack_trace.c: Minor formatting fixes. |
||
|
|
67791773af |
Fix some warnings and type errors that show up on the x86_64 architecture.
Estimated hours taken: 3 Branches: main Fix some warnings and type errors that show up on the x86_64 architecture. browser/io_action.m: Declare is_func in the C code for pickup_io_action to be MR_Bool rather than MR_bool, since it is a (word sized) Mercury bool, not a C boolean. library/construct.m: runtime/mercury_unify_compare_body.h: Provide values for variables even when MR_fatal_error is called, to avoid warnings about uninitialized variables. Add default switch cases which call MR_fatal_error. mdbcomp/rtti_access.m: Pass an int* to MR_find_context, and cast the result to an MR_Integer afterwards. robdd/bryant.h: This code incorrectly assumes that unsigned long will have 32 bits. Flag the error with an XXX. runtime/mercury_deconstruct.c: trace/mercury_trace_internal.c: Cast arity values to int before printing. We don't support arity > 1024 anyway. runtime/mercury_proc_id.h: runtime/mercury_types.h: Add an extra branch to the MR_Proc_Id union for the case when no proc id is present, and add a macro to test for this case. We can't test the enum directly as we did before, because C compilers may report a warning that the test will never succeed (since -1 is not one of the values in the enum). Clarify the comment about the requirement of MR_PredFunc to match prim_data.pred_or_func. Define a macro for the value that indicates there is no proc id. Fix a couple of out-of-date comments. trace/mercury_trace_browse.h: Clarify the comments about the requirement of MR_Browse_Caller_Type, MR_Browse_Format and MR_Query_Type to match their corresponding Mercury types. runtime/mercury_tags.h: Add a comment to point out that enums don't necessarily have the same size as MR_words. runtime/mercury_stack_layout.h: Use the new macro instead of testing directly whether the proc id exists. runtime/mercury_stack_trace.c: runtime/mercury_trace_base.c: runtime/mercury_type_info.c: trace/mercury_trace_internal.c: Use MR_INTEGER_LENGTH_MODIFIER, which is set by `configure', to get the right format specifier when printing integers with the same size as MR_Word. runtime/mercury_type_info.c: Compare pseudo-typeinfos as MR_Integers rather than ints. trace/mercury_trace.c: trace/mercury_trace_tables.c: Provide a dummy value for variables to avoid uninitialized variable warnings. trace/mercury_trace_completion.c: Cast a void* to MR_Integer before casting it to int. It would be nicer to avoid the second cast altogether, but the readline interface requires it. trace/mercury_trace_internal.c: Use MR_trace_is_unsigned when working with MR_Unsigned values. Cast pseudo-typeinfos which are variables to MR_Integer rather than int, to avoid compiler warnings about pointer casts. We cast them to int before printing them, but that is because we know they won't be that big. Parse the argument to the goto command as type MR_Unsigned instead of int, to make it possible to goto an event with a number bigger than 2^31, on 64-bit machines at least. (We already get 200M+ events when the compiler is in a debug grade.) trace/mercury_trace_util.c: trace/mercury_trace_util.h: Provide MR_trace_is_unsigned, which is like MR_trace_is_natural_number except that it works with MR_Unsigned values. trace/mercury_trace_vars.c: Cast void* to MR_Integer rather than int. |
||
|
|
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. |
||
|
|
e854a5f9d9 |
Major improvements to tabling, of two types.
Estimated hours taken: 32
Branches: main
Major improvements to tabling, of two types. The first is the implementation
of the loopcheck and memo forms of tabling for model_non procedures, and the
second is a start on the implementation of a new method of implementing
minimal model tabling, one that has the potential for a proper fix of the
problem that we currently merely detect with the pneg stack (the detection
is followed by a runtime abort). Since this new method relies on giving each
own generator its own stack, the grade component denoting it is "mmos"
(minimal model own stack). The true name of the existing method is changed
from "mm" to "mmsc" (minimal model stack copy). The grade component "mm"
is now a shorthand for "mmsc"; when the new method works, "mm" will be changed
to be a shorthand for "mmos".
configure.in:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
compiler/options.m:
Handle the new way of handling minimal model grades.
scripts/mgnuc.in:
compiler/compile_target_code.m:
Conform to the changes in minimal model grade options.
compiler/table_gen.m:
Implement the transformations required by the loopcheck and memo
tabling of model_non procedures, and the minimal model own stack
transformation.
The new implementation transformations use foreign_procs with extra
args, since there is no point in implementing them both that way and
with separate calls to library predicates. This required making the
choice of which method to use at the top level of each transformation.
Fix an oversight that hasn't caused problems yet but may in the future:
mark goals wrapping the original goals as not impure for determinism
computations.
compiler/handle_options.m:
Handle the new arrangement of the options for minimal model tabling.
Detect simultaneous calls for both forms of minimal model tabling,
and generate an error message. Allow for more than one error message
generated at once; report them all once rather than separately.
compiler/globals.m:
Add a mechanism to allow a fix a problem detected by the changes
to handle_options: the fact that we currently may generate a usage
message more than once for invocations with more than one error.
compiler/mercury_compile.m:
compiler/make.program_target.m:
compiler/make.util.m:
Use the new mechanism in handle_options to avoid generating duplicate
usage messages.
compiler/error_util.m:
Add a utility predicate for use by handle_options.
compiler/hlds_pred.m:
Allow memo tabling for model_non predicates, and handle own stack
tabling.
compiler/hlds_out.m:
Print information about the modes of the arguments of foreign_procs,
since this is useful in debugging transformations such as tabling
that generate them.
compiler/prog_data.m:
compiler/layout_out.m:
compiler/prog_out.m:
runtime/mercury_stack_layout.h:
Mention the new evaluation method.
compiler/goal_util.m:
Change the predicates for creating calls and foreign_procs to allow
more than one goal feature to be attached to the new goal. table_gen.m
now uses this capability.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/typecheck.m:
compiler/unify_proc.m:
Conform to the changes in goal_util.
compiler/code_info.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
Conform to the new the options controlling minimal model
tabling.
compiler/prog_util.m:
Add a utility predicate for use by table_gen.m.
library/std_util.m:
Conform to the changes in the macros for minimal model tabling grades.
library/table_builtin.m:
Add the types and predicates required by the new transformations.
Delete an obsolete comment.
runtime/mercury_grade.h:
Handle the new minimal model grade component.
runtime/mercury_conf_param.h:
List macros controlling minimal model grades.
runtime/mercury_tabling.[ch]:
Define the types needed by the new transformations,
Implement the performance-critical predicates that need to be
hand-written for memo tabling of model_non predicates.
Add utility predicates for debugging.
runtime/mercury_tabling_preds.h:
Add the implementations of the predicates required by the new
transformations.
runtime/mercury_mm_own_stacks.[ch]:
This new module contains the first draft of the implementation
of the own stack implementation of minimal model tabling.
runtime/mercury_imp.h:
Include the new file if the grade needs it.
runtime/Mmakefile:
Mention the new files, and sort the lists of filenames.
runtime/mercury_tabling_macros.h:
Add a macro for allocating answer blocks without requiring them to be
pointed to directly by trie nodes.
runtime/mercury_minimal_model.[ch]:
The structure type holding answer lists is now in mercury_tabling.h,
since it is now also needed by memo tabling of model_non predicates.
It no longer has a field for an answer num, because while it is ok
to require a separate grade for debugging minimal model tabling,
it is not ok to require a separate grade for debugging memo tabling
of model_non predicates. Instead of printing the answer numbers,
print the answers themselves when we need to identify solutions
for debugging.
Change function names, macro names, error messages etc where this is
useful to distinguish the two kinds of minimal model tabling.
Fix some oversights wrt transient registers.
runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
With own stack tabling, each subgoal has its own context, so record
the identity of the subgoal owning a context in the context itself.
The main computation's context is the exception: it has no owner.
Record not just the main context, but also the contexts of subgoals
in the engine.
Add variables for holding the sizes of the det and nondet stacks
of the contexts of subgoals (which should in general be smaller
than the sizes of the corresponding stacks of the main context),
and initialize them as needed.
Initialize the variables holding the sizes of the gen, cut and pneg
stacks, even in grades where the stacks are not used, for safety.
Fix some out-of-date documentation, and conform to our coding
guidelines.
runtime/mercury_memory_zones.[ch]:
Add a function to test whether a pointer is in a zone, to help
debugging.
runtime/mercury_debug.[ch]:
Add some functions to help debugging in the presence of multiple
contexts, and factor out some common code to help with this.
Delete the obsolete, unused function MR_printdetslot_as_label.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_types.h:
Add some more forward declarations of type names.
runtime/mercury_dlist.[ch]:
Rename a field to avoid assignments that dereference NULL.
runtime/mercury_debug.c:
runtime/mercury_memory.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_stacks.[ch]:
trace/mercury_trace_util.c
Update uses of the macros that control minimal model tabling.
runtime/mercury_stack_trace.c:
Provide a mechanism to allow stack traces to be suppressed entirely.
The intention is that by using this mechanism, by the testing system
won't have to provide separate .exp files for hlc grades, nondebug
LLDS grades and debug LLDS grades, as we do currently. The mechanism
is the environment variable MERCURY_SUPPRESS_STACK_TRACE.
tools/bootcheck:
tools/test_mercury:
Specify MERCURY_SUPPRESS_STACK_TRACE.
trace/mercury_trace.c:
When performing retries across tabled calls, handle memo tabled
model_non predicates, for which the call table tip variable holds
a record with a back pointer to a trie node, instead of the trie node
itself.
trace/mercury_trace_internal.c:
When printing tables, handle memo tabled model_non predicates. Delete
the code now moved to runtime/mercury_tabling.c.
Add functions for printing the data structures for own stack minimal
model tabling.
tests/debugger/print_table.{m,inp,exp}:
Update this test case to also test the printing of tables for
memo tabled model_non predicates.
tests/debugger/retry.{m,inp,exp}:
Update this test case to also test retries across memo tabled
model_non predicates.
tests/tabling/loopcheck_nondet.{m,exp}:
tests/tabling/loopcheck_nondet_non_loop.{m,exp}:
New test cases to test loopcheck tabled model_non predicates.
One test case has a loop to detect, one doesn't.
tests/tabling/memo_non.{m,exp}:
tests/tabling/tc_memo.{m,exp}:
tests/tabling/tc_memo2.{m,exp}:
New test cases to test memo tabled model_non predicates.
One test case has a loop to detect, one has a need for minimal model
tabling to detect, and the third doesn't have either.
tests/tabling/Mmakefile:
Add the new test cases, and reenable the existing tc_loop test case.
Rename some make variables and targets to make them better reflect
their meaning.
tests/tabling/test_mercury:
Conform to the change in the name of the make target.
|
||
|
|
8190c16181 |
Get Mercury to work with gcc 3.4. This required fixing several problems.
Estimated hours taken: 16 Branches: main Get Mercury to work with gcc 3.4. This required fixing several problems. One problem that caused errors is that gcc 3.4 is smart enough to figure out that in LLDS grades with gcc gotos, the C functions containing our code are not referred to, and so it optimizes them away. The fix is to ensure that mercury_<module>_init is defined always to call those functions, even if the macro that usually controls this, MR_MAY_NEED_INITIALIZATION, is not defined. The mercury_<module>_init won't be called from the init_modules function in the program's _init.c file, so there is no impact on initialization time, but gcc doesn't know this when compiling a module's .c file, so it doesn't optimize away the code we need. The cost of this change is thus only a small amount of code space. It is worth paying this cost even with compilers other than gcc 3.4 for simplicity. Actually, this size increase seems to be slightly smaller than the size reduction due to the better optimization capabilities of gcc 3.4 compared to gcc 3.2.2. A second problem is that gcc 3.4 warns about casts in lvalues being a deprecated feature. This gave lots of warnings, since we used to define several Mercury abstract machine registers, including MR_succip, MR_hp, MR_sp, MR_maxfr and MR_curfr using lvalue casts. The fix is to have two macros for each of these abstract machine registers, one of type MR_Word that you can assign to (e.g. MR_sp_word), and one of the original type that is of the right type but not an lvalue (e.g. MR_sp). The lvalue itself can't be made the right type, because MR_sp isn't a variable in its own right, but possibly defined to be a machine register. The machine register could made the right type, but only at the cost of a lot of complexity. This problem doesn't apply to the special-purpose Mercury abstract machine registers that can't be allocated to machine registers. Instead of #defining these to slots in MR_fake_reg, we make them global variables of the natural type. This should also make it easier to debug code using these registers. We treat these global variables as if they were machine registers in that MR_save_registers copies values from these global variables to slots reserved for them in the MR_fake_reg array, to allow code to loop over all Mercury abstract machine registers. These saved slots must of course be of type MR_Word, so we again need two macros to refer to them, a lvalue of type MR_Word and an rvalue with the right type. A third problem is that gcc 3.4 warns about conditionals in lvalues being a deprecated feature. This gave a few warnings, since we used to define MR_virtual_reg and MR_saved_reg using lvalues using conditionals. The fix is to have one macro (MR_virtual_reg_value) for use in rvalues and a separate macro which uses an if-then-else instead of a conditional expression (MR_virtual_reg_assign), for assignments. A fourth problem is that gcc 3.4 warns about comma operators in lvalues being a deprecated feature. This gave warnings in the few places where we refer to MR_r(N) for values of N that can map to fake registers directly, since in those cases we preceded the reference to the fake_reg array with a range check of the array index. The fix to this is to move the test to compile time for compiler-generated code. Hand-written code never refers to MR_r(N) for these values, and is very unlikely to do so in the future; instead, it refers to the underlying fake_reg array directly, since that way it doesn't have to worry about which fake registers have their own MR_rN macro and which don't. Therefore no check mechanism for hand-written code is necessary. This change mean that changing the number of MR_rN registers now requires change to the compiler as well as to the runtime system. A fifth problem is that gcc 3.4 by default assumes -fstrict-aliasing at -O2. Since we cast between integers and pointers of different types all the time, and changing that is not practical, at least in the short term, we need to disable -fstrict-aliasing when we enable -O2. NEWS: Note that Mercury now works with gcc 3.4. configure.in: scripts/mgnuc.in: Detect whether the compiler supports -fstrict-aliasing, and if so, whether it assumes it by default with -O2. If the answer is yes to both, make mgnuc specify -fno-strict-aliasing when it specifies -O2. By including it in CFLAGS_FOR_OPT, which gets put into Mercury.config, we also get -f-no-strict-aliasing when mmc invokes the C compiler directly. compiler/llds_out.m: Don't generate #ifdef MR_MAY_NEED_INITIALIZATION around the definitions and calls to the bunch functions, which call the functions we don't want the C compiler to optimize away. Generate the newly required lvalues on the left sides of assignments. We still have code to generate LVALUE_CASTs in some cases, but I don't think those cases ever arise. Add a compile-time check of register numbers. Ideally, the code generator should use stack slots instead of registers beyond the max number, but I don't recall us ever bumping into this limit by accident. compiler/fact_table.m: Use the newly required lvalues on the left sides of assignments in some hand-written C code included in generated .c files. runtime/mercury_regs.h: Make the changes described above to fix the second, third and fourth problems. We still use comma operators in lvalues when counting references to registers, but it is OK to require anyone who wants to enable this feature to use a compiler version that supports comma operators in lvalues or to ignore the warnings. Use the same mapping from Mercury abstract machine registers to the register count array as to the MR_fake_reg array. Have this mapping depend as little as possible on whether we need a real machine register to store MR_engine base, even if it costs a wasted slot in MR_fake_reg. Fix an old inconsistency: treat the Mercury abstract machine registers used for trailing the same way as the other Mercury abstract machine registers, by making MR_save_registers/MR_restore_registers copy them to and from their global variable homes. Document the requirement for the match between the runtime's and the compiler's notions of the maximum MR_rN register number. This requirement makes it harder for users to increase the number of virtual registers, but as far as I know noone has wanted to do this. Change the names of some of the macros to make them clearer. Reorder some parts of this file, and add some documentation, also in the interest of clarity. runtime/mercury_regorder.h: Delete this file after moving its contents, in much modified form, to mercury_regs.h. mercury_regorder.h was always logically part of mercury_regs.h, but was separated out to make it easier to change the mapping from Mercury abstract machine registers to machine registers. However, the cost of incompatibility caused by any such changes would be much greater that any likely performance benefit. runtime/Mmakefile: Remove the reference to mercury_regorder.h. runtime/mercury_regs.[ch]: runtime/mercury_memory_zones.[ch]: Move some functionality dealing with registers from mercury_memory_zones to mercury_regs, since it belongs there. runtime/mercury_regs.[ch]: Add a function to make it easiler to debug changes to map from Mercury abstract machine to MR_fake_reg slots. runtime/mercury_regs.[ch]: runtime/mercury_wrapper.c: Move the code to print counts of register uses from mercury_wrapper.c to mercury_regs.c. Make mercury_wrapper.c call the debugging function in mercury_regs.c if -X is specified in MERCURY_OPTIONS. runtime/mercury_bootstrap.h: Move the old MR_saved_reg and MR_virtual_reg macros from mercury_regs.h to mercury_bootstrap.h to prevent their accidental use. Since they shouldn't be used by user code, move them to the section that is not enabled by default. runtime/mercury_stacks.[ch]: Add _word versions of the macros for stack slots, for the same reason why we need them for Mercury abstract machine registers, and use them. Add global variables for the Mercury abstract machine registers for the gen, cut and pneg stacks. runtime/mercury_heap.h: Change the macros for allocating memory to assign to MR_hp_word instead of MR_hp. runtime/mercury_string.h: Change the macros for allocating strings to accomodate the updates to mercury_heap.h. Also change the expected type of the target to make it MR_String instead of MR_ConstString, since the latter requires casts in the caller. runtime/mercury_trail.h: runtime/mercury_types.h: Move the definition of the type MR_TrailEntry from mercury_trail.h to mercury_types.h, since it is now used in mercury_regs.h. runtime/mercury_accurate_gc.c: runtime/mercury_agc_debug.c: runtime/mercury_calls.h: runtime/mercury_context.[ch]: runtime/mercury_deconstruct_macros.h: runtime/mercury_deep_copy_body.h: runtime/mercury_engine.[ch]: runtime/mercury_hand_compare_body.h: runtime/mercury_hand_unify_body.h: runtime/mercury_ho_call.c: runtime/mercury_layout_util.c: runtime/mercury_make_type_info_body.h: runtime/mercury_minimal_model.c: runtime/mercury_ml_deconstruct_body.h: runtime/mercury_ml_functor_body.h: runtime/mercury_stack_layout.h: runtime/mercury_type_desc.c: runtime/mercury_type_info.c: runtime/mercury_unify_compare_body.h: runtime/mercury_wrapper.c: Conform to the changes in the rest of the runtime. In some cases, fix inconsistencies in indentation. runtime/mercury_stack_trace.c: Add some conditionally compiled debugging code controlled by the macro MR_ADDR_DEBUG, to help debug some problems with stored stack pointers. runtime/mercury_grade.h: Increment the binary compatibility version number. This is needed to avoid potential problems when a Mercury module and the debugger are compiled with different versions of the macros in mercury_regs.h. library/exception.m: Update the code that assigns to abstract machine registers. library/array.m: library/construct.m: library/dir.m: library/io.m: library/string.m: Conform to the new definitions of allocation macros. library/time.m: Delete an unnecessary #include. trace/mercury_trace.c: trace/mercury_trace_declarative.c: trace/mercury_trace_util.c: Conform to the changes in the rest of the runtime. tests/hard_coded/qual_test_is_imported.m: tests/hard_coded/aditi_private_builtin.m: Remove an unnecessary import to avoid a warning. tools/makebatch: Add an option --save-stage2-on-error, that saves the stage2 directory if a bootcheck fails. scripts/ml.in: Make ml more robust in the face of garbage files. |
||
|
|
cdf0383b52 |
Fix a bunch of problems with tabling that I identified in Uppsala.
Estimated hours taken: 32
Branches: main
Fix a bunch of problems with tabling that I identified in Uppsala. These fall
into two categories.
First, the tabling transformations we were using were dividing work up
too finely. This had three bad effects. First, it caused too much time to be
spent on transmitting data to and from library predicates. Second, it made the
transformations hard to document and hard to explain in a paper. Third, it
caused us to misidentify just what the various forms of tabling have in common,
and what forms of tabling work for what determinisms. To fix this problem,
this diff reorients table_builtin.m and table_gen.m from being divided
primarily by determinism to being divided by evaluation method.
Second, we weren't being careful in separating out the parts of the tabling
data structures that are needed only for debugging the tabling system itself.
The fix for this is to introduce a new grade flag, MR_MINIMAL_MODEL_DEBUG,
intended for use by implementors only, to govern whether the tabling data
structures include debug-only components. (If this flag weren't a grade flag,
the sizes of data structures created in files with different values of this
flag could be inconsistent, which is something you don't want when debugging
the complex code of the tabling infrastructure.)
compiler/table_gen.m:
Reorganize the simple (loopcheck and memo) tabling transformations
completely. Instead of separate transformations for model_det and
model_semi predicates, have separate transformations for loopcheck
and memo predicates, since this makes it easier to see (and to ensure)
that the transformation follows the required scheme. Instead of
generating nested if-then-elses, generate switches when possible.
For model_semi loopcheck and memo predicates, generate Mercury code
that obeys our scope rules by not binding output variables in the
condition of the one remaining if-then-else.
Finetune the minimal model tabling transformation by combining some
operations where this improves clarity and performance.
Order the transformation predicates logically, and move the
documentation of each form of tabling next to the code implementing
that form of tabling.
Attach call_table_gen markers to the setup goals that now all
loopcheck, memo and minimal model tabled predicates have,
to avoid having to special case the last lookup goal, and to avoid
having to have separate code for lookups in call tables versus answer
tables.
Generate unique and more meaningful variable names. Change some
predicate names to be more meaningful, both here and in the
transformed code.
Factor out some common code, e.g. for generating lookup goals,
for generating instmap_deltas and for attaching hide_debug_event
markers to goals.
Report errors in cases where the arguments of a tabled predicate
aren't completely input or output.
compiler/hlds_pred.m:
Be more strict about the determinisms of tabled predicates; permit
only the determinisms we really support in all cases, and do not
permit the ones that may happen to work in some cases.
Conform to the change of the name of a builtin.
compiler/det_report.m:
Improve the error message for cases when the determinism is
incompatible with the selected tabling mechanism.
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/options.m:
Handle the new grade component.
library/private_builtin.m:
Provide a semipure analog of the imp predicate, a call to which makes
predicates semipure rather than impure, for use in table_builtin.m.
library/table_builtin.m:
runtime/mercury_tabling_preds.h:
Change the tabling primitives in the ways required by the changes to
the tabling transformations.
Group the primitives by the tabling methods they support, and change
their names to reflect this.
Change the implementation of each of the affected predicates to be
nothing more than the invocation of a macro defined in the new header
file runtime/mercury_tabling_preds.h. The objective of this change
is to make it possible for table_gen.m to replace sequences of calls
to predicates in table_builtin.m with a single extended foreign_proc
goal whose body just invokes the corresponding macros in sequence.
That change should improve performance by allowing the variables
that flow from one tabling primitive to another to stay in x86
registers, instead of being copied to and from Mercury abstract
machines registers, which on the x86 aren't real machine registers.
Benchmarking in Uppsala verified that this is a major cost.
Mark the foreign types used for tabling as can_pass_as_mercury_type;
this was the intended use of that assertion. Make them private to the
module, since the rest of the compiler can now handle this.
Delete the implementations of the predicates for duplicate checking
and for returning answers for completed subgoals. Profiling with gprof
has shown their performance to be critical to the performance of
minimal model tabling overall, and even with our recent changes,
the compiler still can't create optimal C code for them. They are
now implemented with handwritten code in mercury_minimal_model.c.
library/term.m:
Add two utility predicates for use by table_gen.m.
library/Mmakefile:
Since much of the implementation of table_builtin.m is now in
runtime/mercury_tabling_preds.h, make its object files depend
on that header file.
runtime/mercury_conf_params.h:
runtime/mercury_grade.h:
Include MR_MINIMAL_MODEL_DEBUG when computing the grade.
runtime/mercury_minimal_model.[ch]:
Add handwritten code to implement the predicates declared as external
in table_builtin.m.
Conform to the new names of the suspension and completion predicates.
Conform to the presence of debugging fields in tabling data structures
only if MR_MINIMAL_MODEL_DEBUG is defined.
Collect a lot more statistics than before.
Reorder some functions.
Instead of saving the whole generator stack each time, which the new
statistics showed to have O(n^2) behavior on some benchmarks, save only
the segment we need to save.
runtime/mercury_tabling.h:
Conform to the fact that loopcheck and memo predicates now have
separate sets of status values, and import mercury_tabling_preds.h.
runtime/mercury_tabling.c:
runtime/mercury_hash_lookup_or_add_body.h:
Move a huge macro out of mercury_tabling.c to the new file
mercury_hash_lookup_or_add_body.h for ease of editing, and modify it to
gather more statistics.
Make the statistics report easier to read.
runtime/Mmakefile:
Mention mercury_tabling_preds.h and mercury_hash_lookup_or_add_body.h.
runtime/mercury_wrapper.h:
Provide a mechanism (--tabling-statistics in MERCURY_OPTIONS)
that causes the runtime to print tabling statistics at the ends of
executions, for use in benchmarking.
doc/user_guide.texi:
Document --tabling-statistics. (Minimal model tabling is not yet
stable enough to be documented, which is why .dmm isn't documented
either.)
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/mgnuc.in:
Implement the new grade component.
trace/mercury_trace.c:
trace/mercury_trace_internal.c:
Conform to changes in the runtime.
tests/debugger/*.m:
Avoid now invalid combinations of determinism and evaluation method.
tests/debugger/*.exp:
Conform to new goal paths in procedures transformed by tabling.
tests/tabling/*.m:
For tests which had predicate whose determinisms isn't compatible
with the evaluation method, change the determinism if possible,
and the evaluation method otherwise, if either is possible.
Bring these tests up to date with our coding guidelines, since they
may now appear in papers.
tests/tabling/Mmakefile:
Disable the tests whose combination of determinism and evaluation
method is no longer supported, and in which neither one can be changed.
tests/tabling/loopcheck_no_loop.{m,exp}:
Make this test case tougher.
tests/tabling/test_tabling:
Make this script more robust in the face of different kinds of
test case failures.
tests/invalid/loopcheck.{m,err_exp}:
tests/invalid/Mmakefile:
Test that we get the expected error message for an invalid combination
of determinism and evaluation method. The new test invalid/loopcheck.m
is the old test tabling/loopcheck.m.
tests/valid/Mmakefile:
Use a more general pattern to test for minimal model grades,
now that we also use .dmm as a grade component.
|
||
|
|
642c902c90 |
Reduce the sizes of .c and .o files in debug grades by 8%.
Estimated hours taken: 4
Branches: main
Reduce the sizes of .c and .o files in debug grades by 8%.
Add to mdb the capability of putting breakpoints on unify, compare and index
predicates.
compiler/code_gen.m:
Since compiler-generated unify, index and compare pred can be presumed
to be correct, compile them with shallow tracing instead of deep
tracing even if the user asks for deep tracing of the rest of the
module. This saves disk space, compile time and run time.
Move the code for setting the trace level to generate_proc_code,
where it is executed whether we generate code by predicates or by
phases.
compiler/trace_params.m:
Provide a function for use by code_gen.m.
Consider unify and compare predicates to behave as if their address
were taken, since they may be called from builtin.unify or
builtin.compare.
compiler/jumpopt.m:
Do not replace jumps with the block being jumped to if the block
contains an instruction that represents a call to the debugger.
In such cases, the jump is a minor cost in runtime compared to the
call, and the locality benefit from not increasing the code size is
quite likely to exceed that cost.
compiler/llds.m:
Add field names to pragma_c instructions to make the change to jumpopt
easier.
tests/debugger/uci.{inp,exp}:
Update this test case. An update is required since we now generate
fewer events from unify and compare preds due to their now being
shallow traced.
To make this the update easier, use the new capability of putting
breakpoints on unify and compare predicates.
trace/mercury_trace_tables.[ch]:
Expand procedure specifications to allow the specification of unify,
compare and index predicates, and expand the function that checks for
matches between a procedure layout and a procedure specification
accordingly.
Fix two instances of a bug: if a procedure specification has no name,
represent it as NULL, not as a non-NULL pointer to a null character,
since the match function expects only the former.
doc/user_guide.texi:
Document the new definition of procedure specifications.
NEWS:
Mention the new definition of procedure specifications, and expand
on some previous additions to the debugger.
runtime/mercury_stack_trace.c:
Allow mdb breakpoint specifications on uci predicates to be saved.
Factor out some common data structure accesses.
runtime/mercury_proc_id.h:
Change the name of a macro from MR_PROC_ID_COMPILER_GENERATED to
MR_PROC_ID_IS_UCI, for consistency with other names dealing with
unify, compare and index predicates.
runtime/*.[ch]:
trace/*.[ch]:
Conform to the change in mercury_proc_id.h.
|
||
|
|
c80d143cc8 |
The following change is only 98% complete, not 100%.
Estimated hours taken: 120
Branches: main
The following change is only 98% complete, not 100%. I am committing it in
this state because (1) we pass many more test cases in deep profiling grade
with it than without it, and (2) the double maintanance involved in fixing
CVS conflicts is preventing me from doing the last 2%.
Get the deep profiler to work for code that sets up to catch exceptions,
which for the last year or more has included the compiler, and to get it
almost working for code that actually catching exceptions.
The basic problem is that code that throws exceptions will in general cause
several calls to "return" without executing the exit or fail port codes that
the deep profiling transformation inserted into their bodies, and this leaves
the data structure being built by the deep profiling inconsistent. The solution
uses the same approach as we have adopted for the debugger: have the code that
handles the throwing of exceptions simulate a return from each call between
the throw and the catch, updating the deep profiling data structures as needed.
This requires us to be able to walk the stack at runtime not just in debugging
grades but also in deep profiling grades. Since the debugger already has the
mechanisms required for this, we reuse them. The procedure layouts used by the
debugger were designed to have three segments: the procedure stack walk
information, the procedure id, and the execution tracing information. We now
modify this design to make the third segment contain two pointers: to the
execution tracing information (for use by the debugger), and to the procedure's
proc_static structure (for use by deep profiling). Each pointer will be null
unless the pointed-to structure is required by compile-time options.
This common use by the debugger and by deep profiling of the stack-walk
structure and the procedure id structure (which deep profiling used to
generate independently and possibly redundantly) required some rearrangement
of the compiler's version of these data structures.
To make this rearrangement simpler, this diff removes a capability that
we theoretically supported but never used: turning on stack traces without
turning on execution tracing and vice versa. After this diff, stack tracing
is enabled if and only if either execution tracing or deep profiling is
enabled.
The diff also includes improvements in the debugging infrastructure for
debugging deep profiling, which were necessary for the implementation of the
rest of the changes.
compiler/deep_profiling.m:
The code in exception.m needs to know the locations of the variables
that we would pass to the exit or fail port code, so it can simulate
leaving the procedure invocation through the exception port. Without
this information, throwing an exception leaves the deep profiling
data structures of the procedure invocations between throw and catch
in an inconsistent state.
Deep_profiling.m creates these variables, but it doesn't know where
they will be at runtime, so it records their identities; the code
generator will allocate them stack slots and record the numbers of
these stack slots for placement in the now expanded proc layout
structures. Deep profiling used to generate static data structures
separately from the HLDS, but since the code generator now needs
access to them, we store their information in proc_infos in the HLDS.
Instead of passing the addresses of proc_static structures to the deep
profiling port procedures, pass the address of proc_layout structures,
since the information about the identities of procedures are now stored
not in the proc_static structure, but in the proc_layout structure
that points to the proc_static structure.
compiler/hlds_pred.m:
compiler/layout.m:
Move the definitions of the static data structures generated by deep
profiling from layout.m to hlds_pred.m, to allow deep_profiling.m
to store them in proc_infos.
compiler/hlds_pred.m:
compiler/rtti.m:
Move the definition of rtti_proc_label from rtti.m to hlds_pred.m,
since some of the new data structures in hlds_pred.m need it. Despite
its name, the rtti_proc_label type doesn't contain any info that
doesn't belong in the HLDS.
Add some information to the rtti_proc_label type that is now needed
by deep profiling, e.g. record determinisms instead of just code
models. Record explicitly the outcome of some tests that used to be
duplicated in more than one place in the compiler, e.g. for whether
the procedure (as opposed to the predicate) is imported. Change some
of the field names to be more precise about the field's meaning.
compiler/code_gen.m:
Transmit the contents of the deep profiling data structures stored in
the proc_info by deep_profiling.m to continuation_info.m, together
with the layout structures created for execution tracing and the
identities of the variables needed for handling exceptions,
when code generation for a procedure is complete.
After the goal that generates these variables, save them to stack
for use by the exception handler.
compiler/hlds_goal.m:
Add a feature to mark the goal that generates the deep profiling
variables needed by the exception handler.
compiler/hlds_llds.m:
Add a utility predicate for new code in code_gen.m
compiler/continuation_info.m:
Hold the deep profiling information computed by code_gen.m for use by
stack_layout.m.
compiler/layout.m:
compiler/layout_out.m:
Update the definitions of the data structures describing procedure
layouts, and the code writing them out, to reflect the use of some
parts of procedure layouts by deep profiling as well as debugging.
Change the layout structures generated by deep profiling to use
rtti_proc_labels, which are backend independent, instead of
proc_labels, which are specific to the LLDS backend.
Conform to the changes in runtime/mercury_stack_layout.h.
compiler/stack_layout.m:
Generate the updated version of proc_layout structures.
compiler/mercury_compile.m:
compiler/global_data.m:
Conform to the fact that deep profiling no longer generates layout
structures separate from proc_infos.
compiler/llds_out.m:
Register proc_layout structures instead of proc_static structures
for use by runtime/mercury_deep_profiling.c.
compiler/options.m:
compiler/handle_options.m:
Rename the require_tracing option as exec_trace, since this more
directly reflects its meaning.
Instead of having --debug set both require_tracing and stack_trace,
make it set (be the user-visible name of) just exec_trace;
the value of stack_trace is implied.
Turn off the specialization of deep profiling for self-tail-recursive
procedures for now. Due to the changes made by this diff in the data
structures involved in debugging, it cannot be debugged until this
change has been installed. Handling the full language is more important
than a specialization that reduces only stack space overheads, not
runtime overheads.
compiler/compile_target_code.m:
Conform to the changes in options.m and runtime/mercury_grade.h.
compiler/hlds_data.m:
Replace the deep_profiling_proc_static cons_id, and its associated tag,
to deep_profiling_proc_layout, since we now generate addresses of proc
layout structures, not of proc_static structures.
compiler/code_util.m:
Simplify some code based on the new info in rtti_proc_labels.
compiler/bytecode_gen.m:
compiler/dependency_graph.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/proc_label.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/switch_util.m:
compiler/unify_gen.m:
Minor changes to conform to the change from deep_profiling_proc_static
to deep_profiling_proc_layout, to the change in the structure of
rtti_proc_labels, to the changes in types of layout.m, and/or to the
new goal feature.
deep_profiler/measurements.m:
Reserve space for exception counts.
deep_profiler/html_format.m:
Add a column for exception counts.
deep_profiler/profile.m:
deep_profiler/read_profile.m:
Rename the data structures referring to compiler generated unify,
compare and index predicates to avoid misleading names: they are
not the only compiler generated predicates.
deep_profiler/read_profile.m:
runtime/mercury_deep_profiling.c:
Update the string that identifies deep profiling data files.
This is necessary because the format has changed: it now includes
information about exception port counts.
library/exception.m:
In deep profiling grades, execute the exception port code for every
procedure invocation between a throw and a catch, using the procedure
layout structures now generated by the compiler for every procedure.
Rename the function involved to reflect its new, more general purpose.
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code.
Indent C preprocessor directives and foreign_procs according to our
coding standards.
library/profiling_builtin.m:
Change the parameters of the call port code procedures from proc_static
to proc_layout. Reach the proc_static structure from the proc_layout
structure when needed. Include the proc_layout structure in any
messages from assertion failures.
Add some conditionally compiled debugging code.
Give some variables better names.
runtime/mercury_type_info.h:
runtime/mercury_builtin_types.c:
Move the macros required to create the proc_static structures
of unify and compare predicates from mercury_type_info.h
to mercury_builtin_types.c, since the latter is the only file
that needs them.
Use the same macros for creating the proc_static structures
of hand-written unify, compare and compare_reprentation predicates
as for user defined predicates. This required changing their naming
scheme.
runtime/mercury_unify_compare_body.h:
Conform to the new naming scheme.
runtime/mercury_ho_call.c:
Provide the mechanism for mercury_unify_compare_body.h to conform
to the new naming scheme.
Remove the definitions of the proc_static structures for
hand-written unify, compare and compare_reprentation predicates,
since these now have to be defined together with the corresponding
proc_layout structures in mercury_builtin_types.c.
runtime/mercury_builtin_types.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
Handle deep profiling of compare_representation as well as unify
and compare predicates on builtin types.
Handle deep profiling of compare_representation on user-defined types,
since this is done entirely in the runtime, not by compiler generated
predicates.
runtime/mercury_builtin_types_proc_layouts.h:
New header file containing the declarations of the proc layout
structures of the unify, compare and index predicates of builtin types.
Logically, these declarations belong in mercury_builtin_types.h,
but putting them there causes problems for the linker; the details
are explained in the file itself.
runtime/Mmakefile:
Add the new header file.
runtime/mercury_minimal_model.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
runtime/mercury_grade.h:
Replace the MR_REQUIRE_TRACING grade option with MR_EXEC_TRACING.
Besides being better named, the MR_EXEC_TRACING option implies
MR_STACK_TRACE.
Besides the overall binary compatibility version number, add subsidiary
version numbers for binary compatibility in deep profiling and
debugging grades. These will make it easier to bootstrap changes
(such as this) that affect binary compatibility only in such grades.
runtime/mercury_trace_base.c:
trace/mercury_trace.c:
Conform to the new names of the configuration parameters.
runtime/mercury_hand_compare_body.h:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_unify_compare_body.h:
runtime/mercury_ho_call.c:
tools/make_port_code:
Pass proc_layout structures instead of proc_static structures
to deep profiling port routines.
runtime/mercury_conf_param.h:
Make MR_DEEP_PROFILING as well as MR_EXEC_TRACING imply MR_STACK_TRACE,
since deep profiling now needs stack tracing. (MR_STACK_TRACE needs
to be set in this file, because tests in this file depend on knowing
its value, and this file is among the first files included (in this
case indirectly) in mercury_imp.h.)
Document the macros controlling the debugging of deep profiling.
Enable printing of label names when the relevant deep profiling
debugging macro is set.
runtime/mercury_debug.c:
runtime/mercury_deep_rec_depth_actions.h:
runtime/mercury_deep_rec_depth_body.h:
runtime/mercury_exception_catch_body.h:
Get to proc_statics via proc_layouts.
runtime/mercury_deep_call_port_body.c:
runtime/mercury_deep_leave_port_body.c:
Get to proc_statics via proc_layouts.
Allow the debugger to disable deep profiling in Mercury code that is
part of the debugger, not of the user program being executed.
Add some more assertions.
runtime/mercury_engine.[ch]:
Add a new debugging flag that controls at runtime whether we generate
a human readable Deep.debug equivalent to the binary Deep.data files.
(We already had a mechanism for controlling this at compile time,
but this isn't flexible enough.)
runtime/mercury_wrapper.c:
Allow this new debugging flag to be set from MERCURY_OPTIONS.
runtime/mercury_deep_profiling.[ch]:
Respect this new debugging flag.
Update the hand-written proc_static structures representing the runtime
system.
Print out addresses of proc_layout as well as proc_static structures
when assertions fail.
Add a field to the measurement structure for exception port counts,
and write out this field with the other port counts.
Remove procedure id information from proc_static structures,
deep profiling now uses the procedure id in the proc_layout structure.
Add to proc_static structures fields that specify where, if anywhere,
the variables needed by exception.m to executed the exception port code
are in the procedure's stack frame.
Define a global flag that allows the debugger to disable deep
profiling in Mercury code that is part of the debugger, not of the
user program being executed.
Increase type safety by providing two versions of the function
for registering proc_layouts, one for the proc_layout structures
of user-defined predicates and one for unify, compare and index
predicates.
Fix a bug that occurs only if MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS is
defined (which it usually isn't): the initial call count was wrong.
runtime/mercury_deep_profiling_hand.h:
Fix a bug: the handwritten code saving deep profiling variables was
saving them in slots that didn't belong to the relevant stack frame.
Update to conform to the modified definitions of proc_static structures
and the fact that we now reach them via proc_layout structures.
runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
Fix the other side of the bug in mercury_deep_profiling_hand.h
by reserving the right number of stack slots in the stack frames
of the various modes of exception__catch. Make it harder to make
the same bug in the future by getting the needed info from the
place in mercury_stacks.h that defines the structure of the relevant
stack frame.
runtime/mercury_proc_id.h:
Rename the procedure id structure fields referring to compiler
generated unify, compare and index predicates: they are not the only
compiler-generated predicates.
runtime/mercury_stack_layout.h:
Change procedure layout structures to allow them to be used for deep
profiling as well as for debugging, as described in the prologue above.
We don't need the capability to support label layout structures with
links to misnamed proc layout structures, and supporting it is
inconvenient, so delete the capability.
runtime/mercury_debug.c:
runtime/mercury_deep_profiling_hand.h:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_types.h:
trace/mercury_trace_external.c:
Conform to the new names of the procedure id structure fields.
runtime/mercury_std.h:
Add some more arities for MR_PASTE for use in some of the modified
modules in the runtime.
trace/mercury_trace_internal.c:
Disable deep profiling actions in Mercury code that is part of the
debugger, not of the program being debugged.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Make changes parallel to the ones in runtime/mercury_grade.h: delete
--stack-trace as an independent option, and make --debug set its
own option, not --require-tracing.
scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/c2init.in:
scripts/mgnuc.in:
scripts/ml.in:
Conform to the changes in grade options for debugging and for deep
profiling.
tools/bootcheck:
If Mmake.stage.{browser,deep,library,runtime,trace}.params exist,
copy them to become the file Mmake.$dir.params in stage2/$dir
(where dir is derived from the name of the original file in the obvious
way). This allows more flexibility in the creation of the stage2;
for example, it allows some directories (e.g. runtime or library)
to be compiled with more debugging than other directories (e.g.
compiler). This may be required because compiling all directories
with lots of debugging may cause the linker to thrash.
Add an option, --disable-debug-libs, that clobbers the libraries
that should be linked in only in debugging grades.
To conserve disk space, remove Deep.data files created by the bootcheck
by default. Add an option, --keep-deep-data, to preserve these files.
Use a consistent mechanism (test -f) for testing the existence of
all files whose existence is tested.
When recording modification times, record the modification times
of some more files.
tests/hard_coded/Mmakefile:
In deep profiling grades, disable the test cases that we don't now
pass in such grades, and document the reasons for their failure.
Fix the misclassification of the write_binary test case.
|
||
|
|
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.
|
||
|
|
759f76a314 |
Make debugging of minimal model tabling more convenient.
Estimated hours taken: 1.5 Branches: main Make debugging of minimal model tabling more convenient. compiler/handle_options.m: Make -Dmm generate HLDS dumps tailored for understanding the code of procedures transformed by minimal model tabling. runtime/mercury_minimal_model.c: When printing the stack segments being saved, print the values of variables in the affected stack frames. runtime/mercury_stack_trace.c: When dumping the nondet stack, print the name of the procedure that established each ordinary frame, and the goal path at which control will reenter the stack frame, if this information is available. Since mercury_minimal_model.c now asks for the printing of variable values (which is done by Mercury code) while execution is outside the debugger and hence while execution tracing may be enabled, explicitly turn off debugging while in the Mercury code that prints variable values. runtime/mercury_trace_base.[ch]: Provide a simple mechanism for turning off debugging functionality in a region of code. trace/mercury_trace_internal.c: Use the new mechanism in mercury_trace_base to handle turning off debugging output inside the debugger. This also allows us to simplify the code implementing the "flag" mdb command. Make the reports generated by the "unhide_events" and "table_io" commands follow the same format as other commands. Note that mercury_trace_declarative.c doesn't use the new mechanism, because it wants the reexecution of the call being debugged to be exactly the same as its first execution; in particular, turning off I/O tabling for reexecution would generate incorrect results. tests/debugger/nondet_stack.exp*: tests/debugger/tabled_read.exp*: tests/debugger/tabled_read_decl.exp*: tests/debugger/tabled_read_unitize.exp*: tests/debugger/io_stream_test.exp*: tests/debugger/declarative/tabled_read_decl.exp*: Update the expected out of these test cases to reflect the new functionality above. |
||
|
|
1361805c5e |
A bug fix for accurate GC.
Estimated hours taken: 4 Branches: main A bug fix for accurate GC. runtime/mercury_stack_trace.c: In MR_init_nondet_branch_infos(), skip past any deterministic frames until we find the first nondet frame (if any). |
||
|
|
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. |
||
|
|
5f3bc648d7 |
Some more refactoring.
Estimated hours taken: 1 Branches: main Some more refactoring. runtime/mercury_stack_trace.h: runtime/mercury_stack_trace.c: Move the code for dumping the information about the frame category from MR_step_over_nondet_frame() to MR_dump_nondet_stack_frame(). |
||
|
|
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.
|
||
|
|
ab5a7c7acf |
Fix two bugs in the printing of goals where the predicate concerned is an
Estimated hours taken: 6
Branches: main
Fix two bugs in the printing of goals where the predicate concerned is an
compiler-generated unify, compare or index predicate. Improve the mechanisms
for debugging bugs like this.
runtime/mercury_layout_util.[ch]:
Fix bug one: do not return the arity of a type constructor as
the arity of the unify, compare or index predicate of that
type constructor; return the actual arity. When the falsely
returned arity was greater than the actual arity, we could get
core dumps; when it was smaller, the mdb command "print goal"
printed wrong output.
Provide a mechanism for fixing bug two: add a utility function
for computing *correctly* a procedure's original arity and the number
of type_info and/or typeclass_info arguments added by the compiler.
(For convenience, it also returns a predicate/function indication.)
runtime/mercury_stack_layout.h:
Rename the MR_comp_arity field of MR_Compiler_Proc_Id to
MR_comp_type_arity, to make clear that it gives the arity of the type
constructor, not the arity of the predicate, and thus avoid bugs such
as those above.
runtime/mercury_stack_trace.c:
Use the new name of the MR_comp_type_arity field.
trace/mercury_trace_declarative.c:
trace/mercury_trace_vars.c:
Call the new, correct utility function in runtime/mercury_layout_util
to compute how many typeinfo and/or typeclassinfo arguments are added
by the compiler to a unify, compare, or index procedure's arguments,
instead of the different, but logically equivalent and equally wrong
pieces of code here.
trace/mercury_trace_external.c:
Use the new name of the MR_comp_type_arity field. Leave an XXX, since
I am not sure whether Morphine interprets the arity as the arity of the
type constructor or as the arity of the predicate.
runtime/mercury_engine.[ch]:
runtime/mercury_layout_util.c:
Make the printing of locations obtained from RTTI data structures
switchable from mdb, to make problems like this easier to debug.
tests/debugger/uci.{m,inp,exp}:
A new test case to test the proper handling of unify, compare and index
predicates.
tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
Enable the new test case.
|
||
|
|
168500343c |
This change adds new facilities for debugging minimal model tabling, and
Estimated hours taken: 160 Branches: main This change adds new facilities for debugging minimal model tabling, and has several bug fixes found with the aid of those facilities. Most of the diff affects the behavior of the system only in minimal model grades and/or when debugging flags are defined. compiler/ite_gen.m: In minimal model grades, surround the conditions of if-then-elses with calls to three functions. These functions detect when a condition fails due to one or more suspensions, and abort the program. (After resumptions, the condition may actually have solutions, but by then the computation has committed to the wrong path.) compiler/table_gen.m: Change the program transformation for model_non predicates to use a switch instead of nested if-then-elses, to avoid the overhead of wrapping the condition. The version with switches is also a bit easier to debug. The transformation for model_det and model_semi predicates stays as before, because for such predicates finding the status (which we want to switch on) requires computation, not just a lookup. Switch to state variable syntax in the affected predicates. Make the error message for an internal error in loopcheck predicates more precise. Mark the code fragments that modify tabling data structures as impure and code fragments that examine tabling data structures as semipure. runtime/mercury_stacks.[ch]: Implement the new stack of possibly negated contexts that we use to detect false failures due to suspensions in negated contexts. Fix a bug: don't refer to MR_cut_stack[-1]. Shorten the name of the generator stack. runtime/mercury_context.[ch]: runtime/mercury_memory.c: runtime/mercury_wrapper.[ch]: Allocate memory for the new stack of possibly negated contexts. Use the shortened name of the generator stack. runtime/mercury_regorder.h: Allocate a pointer for the new stack of possibly negated contexts. runtime/mercury_minimal_model.[ch]: A new module holding the part of mercury_tabling.[ch] that is specific to minimal model tabling. This version contains tools to help debugging of minimal model tabling, as well as some bug fixes found with the aid of those tools. runtime/mercury_tabling.[ch]: Remove the code moved to mercury_minimal_model.[ch], and add the code moved here from trace/mercury_trace_internal.c. Add prefixes to a bunch of structure fields to make it easier to read code accessing those fields. Add mechanisms to allocate and copy tabling structures with type safety. runtime/mercury_imp.h: #include the new header file, if it is needed. runtime/Mmakefile: Mention the new module, and fix sortedness errors. runtime/mercury_stack_trace.c: Fix a bug that sometimes caused stack traces to abort in minimal model grades: they were trying to get layout information from labels that do not have them, such as do_fail. If MR_TABLE_DEBUG is defined, print the locations of stack frames when doing stack dumps. runtime/mercury_trace_base.h: Export to mercury_stack_trace.c the labels that we use to let the debugger get control at redos and fails, since they don't have layout information. runtime/mercury_types.h: Move typedefs here from mercury_tabling.h, and add typedefs for some newly added types. runtime/mercury_engine.[ch]: Add a table mapping debugging flags to their offsets in the MR_debugflag array, for use in the debugger. runtime/mercury_misc.c: Make the formatting of det stack pointers the same as nondet stack pointers in debugging output. runtime/mercury_debug.[ch]: Add conditionally compiled debugging output when creating temp frames on the nondet stack. library/table_builtin.m: Conform to the new names of some fields. Add a predicate to return the status of a subgoal. Add conditionally compiled debugging code. library/Mmakefile: Make table_builtin.m depend on runtime/mercury_minimal_model.h. trace/mercury_trace.c: Conform to the new names of some fields. trace/mercury_trace_internal.c: Add two new mdb commands, to print the cut stack and the new possibly negated context stack. Add two new mdb commands to print a subgoal and a consumer. Move some of the code to print tabling-related data structures to runtime/mercury_tabling.[ch]. Add a new mdb command to report the values of debugging flags and to set and clear them. Previously, one had to turn on these debugging flags with environment variables, which were problematic because they turned on diagnostic printouts even in Mercury programs that *weren't* being debugged, such as the Mercury compiler when being used to generate the program to be debugged. Now the flags can be turned on from a .mdbrc file, which eliminates much setting and unsetting of environment variables. doc/user_guide.tex: Document the new mdb commands. tests/debugger/mdb_command_test.inp: Test the documentation of the new mdb commands. tests/debugger/completion.exp: Expect the new commands in the command completion test. tests/debugger//nondet_stack.exp*: Expect the new format of det stack pointers. tests/debugger/all_solutions.exp3: tests/debugger/exception_value.exp3: tests/debugger/declarative/catch.exp3: tests/debugger/declarative/ho5.exp3: tests/debugger/declarative/throw.exp3: New expected test cases for use in minimal model grades. They differ from existing expected output files only in the precise phrasing of error messages. tests/debugger/declarative/Mmakefile: Disable the untraced_subgoal test case in .mm grades, since we don't pass it yet. tests/tabling/Mmakefile: Enable the mday test case, now that we pass it. |
||
|
|
a8ffd3680c |
Change the compiler and tools so that .' and not :' is now used as the
Estimated hours taken: 14 Branches: main Change the compiler and tools so that `.' and not `:' is now used as the module separator in all output. Infix `.' now has associativity yfx and priority 10. NEWS: Report the change. configure.in: Amend the test for an up-to-date Mercury compiler to check whether it recognises `.' as a module qualifier. compiler/code_gen.m: compiler/error_util.m: compiler/hlds_out.m: compiler/prog_out.m: compiler/prog_util.m: compiler/rl_exprn.m: compiler/rl_gen.m: compiler/source_file_map.m: compiler/unused_args.m: library/io.m: library/rtti_implementation.m: library/type_desc.m: runtime/mercury_debug.c: runtime/mercury_deconstruct.c: runtime/mercury_stack_trace.c: Change `:' to `.' as module separator for output. compiler/mercury_to_mercury.m: compiler/prog_io_typeclass.m: As above. Fixed a bug where `.' was not being recognised as a module separator. doc/reference_manual.texi: Report the change. library/term_io.m: Ensure that infix `.' is written without surrounding spaces. tests/hard_coded/dot_separator.m: tests/hard_coded/dot_separator.exp: tests/hard_coded/Mmakefile: Test case added. |
||
|
|
a2be486e6c |
Fix English in a comment.
Estimated hours taken: 0.1 Branches: main runtime/mercury_stack_trace.c: Fix English in a comment. |
||
|
|
3abce4e4a3 |
Bootstrap the main branch using the MS Visual C compiler.
Estimated hours taken: 5 Branches: main Bootstrap the main branch using the MS Visual C compiler. README.MS-VisualC: Document that TMPDIR environment variable needs to be set. configure.in: boehm_gc/Mmakefile: runtime/mercury_conf.h.in: runtime/mercury_stack_trace.c: trace/mercury_trace.c: trace/mercury_trace_internal.c: trace/mercury_trace_source.c: trace/mercury_trace_spy.c: configure.in: Check for the _snprintf, sleep and Sleep functions and the windows.h header. runtime/mercury_conf.h.in: Add #defines for the _snprintf, sleep and Sleep functions and windows.h header. boehm_gc/Mmakefile: Compile the collector with debugging turned off so that when linking the debugger with the compiler you don't get duplicate definitions for the C std lib symbols (the debug versions and the release versions). runtime/mercury_stack_trace.c: trace/mercury_trace_internal.c: trace/mercury_trace_spy.c: Use _snprintf if snprintf doesn't exist. trace/mercury_trace.c: Report an error if we attempt to use the external debugger when it's not enabled. trace/mercury_trace_source.c: Use the correct version of sleep for the environment that we are compiling in and if it doesn't exist busy wait for hopefully long enough. |
||
|
|
5f20c37b7a |
Add a mechanism for standardizing the event and call sequence numbers in
Estimated hours taken: 4 Branches: main Add a mechanism for standardizing the event and call sequence numbers in debugger output. The mechanism is a global flag whose value is set from MERCURY_OPTIONS. It is intended to be used only in our own internal testing. runtime/mercury_trace_base.[ch]: Define the global, MR_standardize_event_details. Move the documentation of several globals from the .c to the .h file, since that is where their users will look. Put those globals in a consistent order. Add functions for standardizing event and call sequence numbers, and use them when printing event details. runtime/mercury_wrapper.c: Set MR_standardize_event_details when given the option -de. runtime/mercury_stack_trace.c: library/exception.m: trace/mercury_trace_internal.m: Respect MR_standardize_event_details. tests/Mmake.common: Define the make variable MDB_STD, which is like MDB except it also puts -de in MERCURY_OPTIONS. tests/debugger/Mmakefile: Use MDB_STD instead of MDB for test cases that can benefit from standardizing event and call sequence numbers. Put the rules for the test cases in alphabetical order. tests/debugger/*.exp*: Update expected outputs after this change. |
||
|
|
2aa84cf86d |
In minimal model grades, add an extra slot to nondet stack frames containing
Estimated hours taken: 1 Branches: main In minimal model grades, add an extra slot to nondet stack frames containing the value of MR_sp when the stack frame is created. This will be necessary in future changes that manipulate stack segments. runtime/mercury_stacks.h: Add the extra slot in nondet stack frames in minimal model grades. Rename the similar slot in temp frames from MR_detfr_slot to MR_tmp_detfr_slot; the new slot is MR_table_detfr_slot. Decrease the level of indentation of macro bodies where this was becoming a problem. runtime/mercury_agc_debug.c: runtime/mercury_stack_trace.c: Conform to the changes in mercury_stacks.h. runtime/mercury_stack_trace.c: Switch to four-space indentation to cope with the increased demands on indentation. |
||
|
|
b51c742885 |
Allow the debugger to print higher order values and typeinfos, mainly by
Estimated hours taken: 50
Branches: main
Allow the debugger to print higher order values and typeinfos, mainly by
making the committed choice modes of the predicates in deconstruct.m to
deconstruct higher order values and typeinfos. (The non committed choice
versions will continue to return only placeholders.)
Having the debugger print typeinfos is occasionally useful but more often
it is just distracting. This change therefore adds a new debugger command,
"print_optionals", that toggles the printing of optional values. For now,
the only optional values are typeinfos.
NEWS:
Mention the new capability and the new predicates in the library.
Mention the predicates added previously that allow the caller to
specify how non-canonical terms should be handled, since the change
in their semantics that we anticipated when they were added has now
happened, and their semantics should now be more stable.
browser/browser_info.m:
Use the predicates in the deconstruct.m instead of std_util,
to make the choice of noncanonical term method handling explicit.
browser/browse.m:
When writing small terms using io__write_univ, explicitly use
the same noncanonical term handling method as browser_info.m
library/io.m:
Add predicates to retrieve the current input and output streams.
Add versions of io__write_univ that specify the stream and maybe
the method of handling noncanonical terms.
Add a mode to io__write_list that allows the closure that prints the
list elements to be cc_multi.
All of these are for the new functionality in the browser.
runtime/mercury_ml_expand_body.h:
In committed choice contexts, deconstruct closures as if they were
ordinary terms, with the function symbol being the name of the
predicate/function and the arguments being the terms stored in
the closure.
In committed choice contexts, deconstruct typeinfos as if they were
ordinary terms, with the function symbol being the name of the type
constructor and the arguments being the type constructor's arguments.
runtime/mercury_type_info.[ch]:
Add a new function, MR_collapse_ctor_equivalences, for use by
mercury_ml_expand_body.h.
Delete a redundant function comment.
library/deconstruct.m:
Document the changes in the behavior of the predicates defined in this
module as a result of the change to mercury_ml_expand_body.h.
runtime/mercury_ho_call.h:
runtime/mercury_stack_layout.h:
Add prefixes on structure field names that did not have them.
browser/dl.m:
Add prefixes where needed by the changes to mercury_ho_call.h.
runtime/mercury_layout_util.[ch]:
Remove the first argument of MR_materialize_closure_typeinfos, since
its correct value is always the same part of the second argument.
runtime/mercury_deep_copy_body.h:
Do not pass the first argument of MR_materialize_closure_typeinfos.
Add field name prefixes where necessary.
compiler/modules.m:
The mercury_builtin module is no longer part of the library.
compiler/pd_debug.m:
compiler/rl_analyze.m:
Minor updates to avoid trying to take the address of io__write_list,
since it now has more than one mode.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
trace/mercury_trace_vars.[ch]:
Add a parameter to MR_trace_browse_all_on_level that specifies
whether we should print values of type type_info.
trace/mercury_trace_vars.c:
Do not ignore predicates and functions anymore.
runtime/mercury_stack_trace.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
Pass the new parameter of MR_trace_browse_all_on_level.
trace/mercury_trace_internal.c:
Implement the "print_optionals" command.
doc/user_guide.texi:
Document the "print_optionals" command.
tests/debugger/mdb_command_test.inp:
Test the documentation of "print_optionals".
tests/debugger/higher_order.{m,inp,exp,exp2}:
A new test case to exercise the ability to print higher order values.
Note that the format of the predicate names in the output should be
improved, but that is a separate change since doing it the right way
requires bootstrapping.
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/nondet_stack.exp*:
Update the expected output to reflect the fact that nondet stack dumps,
being intended for debugging, include type_infos.
tests/debugger/tabled_read_decl.exp*:
Update the expected output to reflect the fact that for maximum
usefulness, the printing of I/O action atoms prints meaningful
type_infos.
tests/hard_coded/deconstruct_arg.*:
tests/hard_coded/write_reg1.*:
Expand these tests to check that we handle higher order values
correctly not just when canonicalizing but also in committed choice
modes.
|
||
|
|
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. |
||
|
|
5b16c5f3d0 |
Fix bugs in the code to parse and match procedure
Estimated hours taken: 2.5 Branches: main Fix bugs in the code to parse and match procedure specifications for breakpoints: - handle nested modules. - handle names containing '/' and '-'. - use the correct arity for functions, not the arity of the corresponding predicate. trace/mercury_trace_tables.c: Fix the bugs. runtime/mercury_stack_layout.h: Add a macro to adjust the arity of functions recorded in MR_Proc_Layouts for printing. runtime/mercury_stack_trace.c: Print the correct arity of functions in stack traces and debugger events. tests/debugger/breakpoints.m: tests/debugger/breakpoints.print_list.m: tests/debugger/breakpoints.inp: tests/debugger/breakpoints.exp: Add test cases. tests/debugger/existential_type_classes.exp: tests/debugger/polymorphic_output.exp3: tests/debugger/declarative/func_call.exp: Update expected output. (I'll update the other output files after this change is installed). |
||
|
|
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.
|
||
|
|
bb52e7bc8d |
Add support for `--gc none' to the MLDS->C back-end,
Estimated hours taken: 8 Branches: main Add support for `--gc none' to the MLDS->C back-end, i.e. support the `hlc' and `hl' grades. runtime/mercury_float.h: Extra some of the code from MR_float_to_word() out into a new macro MR_make_hp_float_aligned(), for use in MR_box_float(). runtime/mercury.h: If CONSERVATIVE_GC is not defined, include "mercury_regs.h" and "mercury_engine.h", so that we get the definition of MR_hp, and "mercury_overflow.h", for MR_heap_overflow_check(). Define MR_new_object() and MR_box_float() correctly for the !CONSERVATIVE_GC case. runtime/mercury_context.h: runtime/mercury_context.c: runtime/mercury_engine.c: runtime/mercury_debug.c: runtime/mercury_thread.c: runtime/mercury_stack_trace.c: trace/mercury_trace_util.c: Add `#ifndef MR_HIGHLEVEL_CODE ... #endif' wrappers around sections of code that are specific to the LLDS back-end. runtime/mercury_wrapper.c: library/benchmarking.m: Initialize (in mercury_wrapper.c) and use (in benchmarking.m) the MercuryEngine struct in the !CONSERVATIVE_GC case, as well as in the !MR_HIGHLEVEL_CODE case. The MercuryEngine struct is needed because that is where the heap pointer and heap zone are stored. library/table_builtin.m: Use the correct names for type_ctor_infos when MR_HIGHLEVEL_CODE is enabled. (Previously this was not an issue because these type_ctor_infos were only being used in the !CONSERVATIVE_GC case.) tests/hard_coded/Mmakefile: For the test cases which use lots of memory, increase the heap size (using the MERCURY_OPTIONS environment variable) rather than compiling them with `--gc conservative'. This avoids spurious test case failures when running the tests via `tools/bootcheck --grade hlc --no-bootcheck'. |
||
|
|
04e614485d |
Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500 Branches: main Implement deep profiling; merge the changes on the deep2 branch back onto the trunk. The main documentation on the general architecture of the deep profiler is the deep profiling paper. doc/user_guide.texi: Document how to use the deep profiler. deep_profiler: deep_profiler/Mmakefile: A new directory holding the deep profiler and its mmakefile. Mmakefile: Add targets for the new directory. Add support for removing inappropriate files from directories. deep_profiler/interface.m: The deep profiler consists of two programs: mdprof_cgi.m, which acts as a CGI "script", and mdprof_server.m, which implements the server process that the CGI script talks to. Interface.m defines the interface between them. script/mdprof.in: A shell script template. ../configure uses it to generate mdprof, which is a wrapper around mdprof_cgi that tells it how to find mdprof_server. deep_profiler/mdprof_cgi.m: The CGI "script" program. deep_profiler/mdprof_server.m: The top level predicates of the server. deep_profiler/profile.m: The main data structures of the server and their operations. deep_profiler/read_profile.m: Code for reading in profiling data files. deep_profiler/startup.m: Code for post-processing the information in profiling data files, propagating costs from procedures to their ancestors and performing various kinds of summaries. deep_profiler/server.m: Code for responding to requests from the CGI script. deep_profiler/cliques.m: Code to find cliques in graphs. deep_profiler/array_util.m: deep_profiler/util.m: Utility predicates. deep_profiler/dense_bitset.m: An implementation of (part of) the set ADT with dense bit vectors. deep_profiler/measurements.m: Operations on profiling measurements. deep_profiler/timeout.m: An implementation of a timeout facility. deep_profiler/conf.m: Functions that depend on autoconfigured settings. configure.in: Find out what command to use to find the name of the local host. Install deep profiling versions of the standard library along with the other profiling versions. runtime/mercury_conf.h.in: Add some macros for deep_profiler/conf.m to use. library/profiling_builtin.m: runtime/mercury_deep_call_port_body.h: runtime/mercury_deep_leave_port_body.h: runtime/mercury_deep_redo_port_body.h: A new library module that implements deep profiling primitives. Some of these primitives have many versions, whose common code is factor is factored out in three new include files in the runtime. compiler/deep_profiling.m: New module to perform the program transformations described in the paper. compiler/notes/compiler_design.html: Document the new compiler module. compiler/mercury_compiler.m: Invoke the new module in deep profiling grades. Allow global static data to be generated by deep_profiling.m. compiler/options.m: Add options to turn on deep profiling and (for benchmarking purposes) control its implementation. Add an optiooption disable tailcall optimization in the LLDS backend, to help benchmarking deep profiling. compiler/jumpopt.m: compiler/optimize.m: Obey the option to disable tailcalls. compiler/handle_options.m: Handle the implications of deep profiling. compiler/modules.m: In deep profiling grades, automatically import profiling_builtin.m. compiler/prog_util.m: doc/Makefile: library/library.m: Handle the new builtin module. compiler/export.m: In deep profiling grades, wrap deep profiling code around exported procedures to handle the "unscheduled call" aspects of callbacks to Mercury from the foreign language. compiler/higher_order.m: profiler/demangle.m: util/demangle.c: When creating a name for a higher-order-specialized predicate, include the mode number in the name. compiler/add_trail_ops.m: compiler/type_util.m: Move c_pointer_type from add_trail_ops to type_util, so it can also be used by deep_profiling.m. compiler/hlds_goal.m: Add a new goal feature that marks a tail call, for use by deep_profiling.m. compiler/hlds_pred.m: Add a new field to proc_info structures for use by deep_profiling.m. Add a mechanism for getting proc_ids for procedure clones. Remove next_proc_id, an obsolete and unused predicate. compiler/hlds_data.m: Add a new cons_id to refer to the proc_static structure of a procedure. compiler/bytecode_gen.m: compiler/code_util.m: compiler/dependency_graph.m: compiler/hlds_out.m: compiler/mercury_to_mercury.m: compiler/ml_unify_gen.m: compiler/opt_debug.m: compiler/prog_rep.m: compiler/rl_exprn.m: compiler/switch_util.m: compiler/unify_gen.m: Trivial changes to handle the new cons_id, goal feature and/or proc_info argument. compiler/rtti.m: Add a utility predicate for extracting pred_id and proc_id from an rtti_proc_label, for use by hlds_out.m compiler/layout.m: compiler/layout_out.m: compiler/llds.m: compiler/llds_common.m: Add support for proc_static and call_site_static structures. compiler/layout_out.m: compiler/llds_out.m: Add code for the output of proc_static structures. compiler/code_util.m: Make code_util__make_proc_label_from_rtti a function, and export it. util/mkinit.c: compiler/llds_out.m: compiler/layout.m: compiler/modules.m: Add support for a fourth per-module C function, for writing out proc_static structures (and the call_site_static structures they contains). Since proc_static structures can be referred to from LLDS code (and not just from other static structures and compiler-generated C code), reorganize the declarations of static structures slightly. Change the schema for the name of the first per-module C function slightly, to make it the addition of the fourth function easier. The scheme now is: mercury__<modulename>__init mercury__<modulename>__init_type_tables mercury__<modulename>__init_debugger mercury__<modulename>__write_out_proc_statics Improve formatting of the generated C code. library/*.m: runtime/mercury.c: runtime/mercury_context.c: runtime/mercury_engine.c: runtime/mercury_ho_call.c: runtime/mercury_tabling.c: runtime/mercury_trace_base.c: runtime/mercury_wrapper.c: trace/mercrury_trace.[ch]: trace/mercrury_trace_declarative.c: trace/mercrury_trace_external.c: trace/mercrury_trace_internal.c: Conform to the new scheme for initialization functions for hand-written modules. compiler/mercury_compile.m: library/benchmarking.m: runtime/mercury_conf_param.h: runtime/mercury.h: runtime/mercury_engine.c: runtime/mercury_goto.c: runtime/mercury_grade.h: runtime/mercury_ho_call.c: runtime/mercury_label.[ch]: runtime/mercury_prof.[ch]: Add an MR_MPROF_ prefix in front of the C macros used to control the old profiler. compiler/handle_options.m: runtime/mercury_grade.h: scripts/canonical_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: Make deep profiling completely separate from the old profiling system, by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME and the compiler option --profile-time. library/array.m: library/builtin.m: library/std_util.m: runtime/mercury_hand_unify_body.h: runtime/mercury_hand_compare_body.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of hand-written unification and comparison procedures. Make the reporting of array bounds violations switchable between making them fatal errors, as we currently, and reporting them by throwing an exception. Throwing an exception makes debugging code using arrays easier, but since exceptions aren't (yet) propagated across engine boundaries, we keep the old behaviour as the default; the new behaviour is for implementors. runtime/mercury_deep_profiling_hand.h: New file that defines macros for use in Mercury predicates whose definition is in hand-written C code. library/exception.m: runtime/mercury_exception_catch_body.h: runtime/mercury_stacks.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of the various modes of builtin_catch. Provide a function that C code can use to throw exceptions. library/benchmarking.m: library/exception.m: library/gc.m: library/std_util.m: runtime/mercury_context.[ch]: runtime/mercury_engine.[ch]: runtime/mercury_debug.c: runtime/mercury_deep_copy.c: runtime/mercury_overflow.h: runtime/mercury_regs.h: runtime/mercury_stacks.h: runtime/mercury_thread.c: runtime/mercury_wrapper.c: Add prefixes to the names of the fields in the engine and context structures, to make code using them easier to understand and modify. runtime/mercury_deep_profiling.[ch]: New module containing support functions for deep profiling and functions for writing out a deep profiling data file at the end of execution. runtime/mercury_debug.[ch]: Add support for debugging deep profiling. Add support for watching the value at a given address. Make the buffered/unbuffered nature of debugging output controllable via the -du option. Print register contents only if -dr is specified. runtime/mercury_goto.h: runtime/mercury_std.h: Use the macros in mercury_std.h instead of defining local variants. runtime/mercury_goto.h: runtime/mercury_stack_layout.h: runtime/mercury_stack_trace.c: runtime/mercury_tabling.c: trace/mercury_trace.c: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_vars.c: Standardize some of the macro names with those used in the debugger paper. runtime/mercury_heap.h: Add support for memory profiling with the deep profiler. runtime/mercury_prof.[ch]: runtime/mercury_prof_time.[ch]: Move the functionality that both the old profiler and the deep profiler need into the new module mercury_prof_time. Leave mercury_prof containing stuff that is only relevant to the old profiler. runtime/mercury_prof.[ch]: runtime/mercury_strerror.[ch]: Move the definition of strerror from mercury_prof to its own file. runtime/mercury_wrapper.[ch]: Add support for deep profiling. Add suppory for controlling whether debugging output is buffered or not. Add support for watching the value at a given address. runtime/Mmakefile: Mention all the added files. scripts/mgnuc.in: Add an option for turning on deep profiling. Add options for controlling the details of deep profiling. These are not documented because they are intended only for benchmarking the deep profiler itself, for the paper; they are not for general use. tools/bootcheck: Compile the deep_profiler directory as well as the other directories containing Mercury code. Turn off the creation of deep profiling data files during bootcheck, since all but one of these in each directory will be overwritten anyway. Add support for turning on --keep-objs by default in a workspace. tools/speedtest: Preserve any deep profiling data files created by the tests. trace/mercury_trace.c: Trap attempts to perform retries in deep profiling grades, since they would lead to core dumps otherwise. util/Mmakefile: Avoid compile-time warnings when compiling getopt. tests/*/Mmakefile: tests/*/*/Mmakefile: In deep profiling grades, switch off the tests that test features that don't work with deep profiling, either by design or because the combination hasn't been implemented yet. |
||
|
|
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. |
||
|
|
3f18f1c4f4 |
Add some missing MR_ prefixes.
Estimated hours taken: 0.2 runtime/*.[ch]: Add some missing MR_ prefixes. |
||
|
|
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. |