Avoid these errors, seen when compiling with a gcc 10 snapshot:
error: ‘strncpy’ output truncated before terminating nul copying 3 bytes
from a string of the same length [-Werror=stringop-truncation]
runtime/mercury_trace_term.c:
Replace use of strncpy with memcpy in a private function.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
runtime/*.[ch]:
trace/*.[chyl]:
As above. In some places, improve comments, e.g. by expanding contractions
such as "we've". Add #ifndef guards against double inclusion around
the trace/*.h files that did not already have them.
tools/*:
Make the corresponding changes in shell scripts that generate .[ch] files
in the runtime.
tests/*:
Conform to a slight change in the text of a message.
Move all .h and .c files to four-space indentation without tabs,
if they weren't there already.
Use the same vim line for all .h and .c files.
Align all backslashes at the ends of lines in macro definitions.
Align close comment signs.
In some places, fix inconsistent indentation.
Fix a bunch of comments. Add XXXs to a few of them.
Estimated hours taken: 6
Branches: main
Provide support for list syntax and quoted function symbols in the terms
that appear in breakpoint conditions.
runtime/mercury_trace_term.[ch]:
Provide the new capability when creating terms from strings.
Since with nonempty lists, the function symbol of the created term
("[|]") does not appear in the original string, do not try to reuse
the memory of the string for the memory of the function symbols;
instead, make a copy of each function symbol as needed. This also
makes the code simpler by avoiding the need to mangle the original
string to null-terminate these function symbols.
Add a mechanism for reporting the location and nature of syntax errors.
Don't assume that the initial string has no spaces.
trace/mercury_trace_spy.[ch]:
Don't record the strings from which the terms in breakpoint conditions
came from, since function symbols' memory no longer comes from there,
and thus we don't have to free them when the breakpoint is deleted.
trace/mercury_trace_cmd_breakpoint.c:
Use the new mechanism for reporting the details of syntax errors in
terms.
Include spaces in the string from which terms are constructed
at the points at which the user included spaces, since the absence
of such spaces in any reports of syntax errors would be surprising.
Delete the temporary memory for strings containing terms as soon
as they have been used to construct their terms.
trace/mercury_trace_internal.c:
Document a problem.
trace/Mmakefile:
Rebuild this directory automatically if a few more headers in the
runtime change.
doc/user_guide.texi:
Document the new capability.
tests/debugger/queens.{inp,exp,exp2}:
Test the new capability.
Estimated hours taken: 32
Branches: main
The objective of this diff is to switch from a table of solver events built
into the compiler (and eventually the debugger) into a table of events
defined by a file provided by the user to the compiler, which the compiler
then records in the executable for use by the debugger.
The current design, for speed of implementation, uses temporary files parsed
by a bison-generated parser. Since the compiler needs to be able to invoke
the parser even if it is compiled in a non-debug grade, the parser is in
a new library, the eventspec library, that is always linked into the Mercury
compiler and is always linked into any Mercury program with debugging enabled
(but is of course linked only once into a Mercury compiler which has debugging
enabled).
Modify the debugger to give it the ability to print the attributes of
user-defined events (for now, only the non-synthesized attributes).
Implement a new debugger command, "user", which goes to the next user-defined
event.
configure.in:
Require flex and and bison to be available.
doc/user_guide.texi:
Document user defined events and the new debugger capabilities.
doc/mdb_categories:
Include "user" in the list of forward movement commands.
Fix some earlier omissions in that list.
runtime/mercury_stack_layout.h:
Include an event number in the user-defined event structure.
Include a string representing an event set specification in module
layout structures.
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.[ch]:
runtime/mercury_types.h
Switch from solver events to user events in names.
runtime/mercury_trace_term.[ch]:
Provide a representation of flat terms, for use in representing
the calls that generate synthesized attributes.
Ensure that exported field names have an MR_ prefix.
browser/cterm.m:
Conform to the change to runtime/mercury_trace_term.h.
scripts/c2init.in:
scripts/ml.in:
Include the eventspec library in programs compiled with debugging
enabled.
compiler/Mmakefile:
Include the eventspec library in the compiler.
compiler/options.m:
Add a new option, --event-spec-file-name, that allows the user to
specify the set of user-defined events the program may use.
compiler/handle_options.m:
Set this optimization from an environment variable (which may be
set by the mmc script) if the new option is not explicitly given.
compiler/prog_data.m:
Define the data structures for the compiler's representation of the
event set specification.
Move some definitions around to group them more logically.
compiler/hlds_module.m:
Include the event set specification as a new field in the module_info.
compiler/prog_event.m:
Add the code for invoking the parser in the eventspec library,
and for converting the simple term output by the parser to the
compiler own representation, which contains more information
(to wit, the types of the function attributes) and which has had
a whole bunch of semantic checks done on it (e.g. whether synthesized
attributes depend on themselves or on nonexistent attributes).
Provide a function to generate a canonicalized version of the event
specification file.
compiler/module_qual.m:
compiler/equiv_type.m:
Process event spec specifications as well as items, to module qualify
the names of the types of event arguments, and expanding out
equivalence types.
In equiv_type.m, rename some variables to make clear what kind of info
they represent.
compiler/mercury_compile.m:
Process the event set specification file if one has been selected:
read it in, module qualify it, expand its equivalence types, and add
to the module_info.
compiler/compile_target_code.m:
Include the event_spec library when linking debuggable executables.
compiler/call_gen.m:
compiler/continuation_info.m:
compiler/trace_gen.m:
compiler/trace_params.m:
mdbcomp/prim_data.m:
mdbcomp/trace_counts.m:
runtime/mercury_goto.h:
Generate user-defined events instead of solver events.
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
Include a canonicalized version of the event specification file
in the module layout if the module has any user-defined events.
compiler/code_info.m:
compiler/llds_out.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/typecheck.m:
Conform to the changes above.
compiler/passes_aux.m:
Rename a predicate to avoid an ambiguity.
trace/Mmakefile:
Add the definition and rules required to build the eventspec library.
trace/mercury_event_scanner.l:
trace/mercury_event_parser.y:
A scanner and a parser for reading in event spec specifications.
trace/mercury_event_spec_missing.h:
Provide the declarations that should be (but aren't) provided by
flex and bison.
trace/mercury_event_spec.[ch]:
The main module of the eventspec library. Provides functions to read
in event set specifications from a file, and to write them out as a
Mercury term in the form needed by the compiler.
trace/mercury_trace_tables.c:
If the module layouts being registered include event set
specifications, then check their consistency. Make the specification
and the consistency indication available to other modules.
trace/mercury_trace_internal.c:
During initialization, if the modules contain a consistent set of event
set specifications, then read that specification into the debugger.
(We don't yet make use of this information.)
Add an extra mdb command, "user", which goes forward to the next
user-defined event.
trace/mercury_trace.[ch]:
trace/mercury_trace_cmd_forward.[ch]:
Implement the new mdb command.
trace/mercury_trace_vars.[ch]:
For user-defined events, include the attributes' values among the
values that can be printed or browsed.
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_declarative.c:
Minor changes.
scripts/scripts/prepare_tmp_dir_grade_part:
Copy the .y and .l files to the tmp dir we use for installs.
tools/bootcheck:
Copy the .y and .l files of the trace directory to stage 2.
tools/lmc.in:
Include the eventspec library when linking debuggable executables.
tests/debugger/user_event.{m,inp,exp}:
tests/debugger/user_event_spec:
New test case to test the new functionality.
tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/completion.exp:
Expect the new "user" mdb command in the completion output.
Estimated hours taken: 16
Branches: main, release
Implement a new mdb command, "condition", which associates a condition with
an existing breakpoint. The condition is a match between a variable live at
the breakpoint, or a part thereof, and a term provided as part of the condition
command. If execution arrives at the breakpoint but the match doesn't have the
required outcome, execution will continue without stopping.
NEWS:
Mention the new capability.
doc/user_guide.texi:
Document the new capability.
runtime/mercury_trace_term.[ch]:
This new module has facilities for converting strings to a structured
representation of terms. The debugger uses this representation for the
term being matched.
runtime/Mmakefile:
Add the new module to the list of modules in the runtime library.
browser/cterm.m:
This new module tests whether a value in the program being debugged
matches a term represented by the data structure defined in
mercury_trace_term.
browser/mdb.m:
Include the new module in the browser library.
trace/mercury_trace_spy.[ch]:
Change the code that checks for breakpoints to check breakpoints'
conditions.
Fix an old bug: set the number of the most recent breakpoint
even when reusing an existing slot.
trace/mercury_trace_vars.c:
Change the code that checks for breakpoints to also evaluate the
condition, if any.
Provide the facilities required to implement conditions. Besides
exporting some previously private functions, this involved breaking up
two existing functions into two pieces each, because condition checking
wanted to reuse only parts of them.
Modify the implementation of the functions manipulating breakpoints
to handle the new parts of spy point structures.
Modify the way we delete spy point structures to make doubly sure
that we don't free memory twice; it is now MR_delete_spy_point that
sets the spy_exists field to FALSE, after checking it.
Give more meaningful names to some variables.
trace/mercury_trace_internal.[ch]:
Implement the condition command.
Conform to the changes in mercury_trace_vars.c
When the condition of a breakpoint cannot be evaluated, print an error
message.
Extend the command parser to support double quotes, since this is now
needed to allow strings in terms in the condition command.
Flush any error messages resulting from an mdb command immediately
after the command. This was useful in debugging the change.
tests/debugger/cond.{m,inp,exp*}:
Add this new test case to test the new capability.
tests/debugger/Mmakefile:
Include the new test case in the list of test cases.
tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
Update to reflect the new command.
tests/debugger/cmd_quote.exp:
Update the error message.