The Windows _snprintf family of functions do not guarantee null
termination when the output is truncated so cannot be used as direct
replacements for the snprintf functions. Also, the _snprintf functions
have different return values from the C99 snprintf functions when output
is truncated (like some older snprintf implementations).
Furthermore, on Windows snprintf/vsnprintf may be synonyms for
_snprintf/_vsnprintf so cannot be relied upon to terminate their outputs
either, even if the functions exist.
runtime/mercury_string.c:
runtime/mercury_string.h:
Define MR_snprintf and MR_vsnprintf as macro synonyms for
snprintf/vsnprintf ONLY if _snprintf/_vsnprintf do not exist.
Otherwise, implement MR_snprintf and MR_vsnprintf functions
that behave like the C99 functions, in terms of _vsnprintf.
Require that either snprintf/vsnprintf or _snprintf/_vsnprintf
are available. This should be true on all systems still in use.
runtime/mercury_debug.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_runtime_util.c:
runtime/mercury_stack_layout.c:
runtime/mercury_stack_trace.c:
runtime/mercury_stacks.c:
runtime/mercury_tabling.c:
runtime/mercury_threadscope.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
trace/mercury_trace_completion.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_spy.c:
trace/mercury_trace_vars.c:
bytecode/mb_disasm.c:
Use MR_snprintf instead of snprintf/_snprintf
and MR_vsnprintf instead of vsnprintf/_vsnprintf.
Drop code paths using sprintf as a fallback.
trace/mercury_trace_completion.c:
Use rl_filename_completion_function rather than
filename_completion_function; the latter name is deprecated (and, in fact,
is not present on some systems).
Support the use of the editline library as an alternative to GNU readline for
the debugger command-line prompt. The former has a more permissive license
than the latter. If licensing is not an issue then GNU readline is the
preferable choice (e.g. feature wise); as such it is the default option.
NOTE: there are (apparently) two editline libraries, one derived from NetBSD
and one from Minix -- this diff adds support for the former. (Using the latter
should just be a matter of using a different header file and supplying a
different library name to link against, but I haven't tried that yet.)
m4/mercury.m4:
Add a configuration check for editline.
configure.ac:
Check the presence of editline.
runtime/mercury_conf.h.in:
Replace the macro MR_NO_USE_READLINE with MR_USE_READLINE which
is defined if GNU readline is available and the user has not
forbidden its use.
Add a new macro MR_USE_EDITLINE which does the same for editline.
Add a new macro that is defined if the header editline/readline.h
is present.
trace/mercury_trace_completion.c:
trace/mercury_trace_readline.c:
Use editline in place of readline if appropriate.
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.
trace/Mmakefile:
trace/mercury_trace_readline.c:
Do not disable C compiler warnings when compiling this file.
This was previously done in order to avoid warnings from ancient
versions of the readline headers.
trace/mercury_trace_completion.c:
Add a missing const qualifier to a declaration.
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.
Mdb supports the location of a breakpoint to be specified either
as a procedure name, or as a source location in the form of a
filename/linenumber pair. It has long had readline auto-complete
on procedure names; this diff adds auto-complete on source locations as well.
NEWS:
Announce the new capability.
trace/mercury_trace_completion.{h,c}:
Add a completer for break commands that is separate from the existing
one that completes only procedure specifications. The new one completes
on both those AND on the filename:linenumber of all the events in all
the debuggable modules of the program.
Move all the forward declarations of static functions to the top
of mercury_trace_completion.c, and put them in the same order as
the corresponding definitions.
trace/mercury_trace_internal.c:
Use the new completer for the "break" command.
trace/mercury_trace_spy.c:
trace/mercury_trace_tables.c:
Fix some documentation.
tests/debugger/completion.{inp,exp}:
Update this test. Update the input, because in some cases, this diff
causes the shortest unambiguous extension of the current line so far
to become shorter, due to the addition of source locations to the set
of strings being given to readline. And update the output to show
the now-expanded set of matching strings at the points at which
completion is taking place.
Except where noted otherwise below most of these warnings relate to implicit
conversions between 64- and 32-bit integers or the signedness of integers
differing in spots.
library/construct.m:
Delete an unused local variable in the implementation of get_functor_lex.
library/bitmap.m:
The function MR_bitmap_cmp returns an MR_Integer not an int.
library/thread.semaphore.m:
Change the count field of the ML_SEMAPHORE_STRUCT structure into
an MR_Integer (which is what gets passed in).
trace/mercury_trace_declarative.c:
Avoid a warning about fprintf being called where its second argument
is not a string literal. (In this case it can be replaced by a call
to fputs.)
library/io.m:
mdbcomp/rtti_access.m:
trace/mercury_trace.c:
trace/mercury_trace_cmd_breakpoint.c:
trace/mercury_trace_cmd_help.c:
trace/mercury_trace_completion.m:
trace/mercury_trace_declarative.[ch]:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_source.c:
trace/mercury_trace_tables.c:
trace/mercury_trace_vars.c:
util/info_to_mdb.c:
util/mfiltercc.c:
util/mdemangle.c:
util/mkinit.c:
util/mkinit_erl.c:
util/mkinit_common.h:
util/mkinit_common.c:
As above.
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).
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.
Estimated hours taken: 40
Branches: main
Add support for command line completion to mdb.
NEWS:
Document the change.
trace/mercury_trace_completion.{c,h}:
Define the framework for completion.
Examine command lines to determine which completers to use.
trace/mercury_trace_alias.{c,h}:
trace/mercury_trace_help.{c,h}:
trace/mercury_trace_internal.{c,h}:
trace/mercury_trace_tables.{c,h}:
trace/mercury_trace_vars.{c,h}:
Define context-specific completers.
trace/mercury_trace_help.c:
Record all help topics in an array for use by the completer.
trace/mercury_trace_internal.c:
Add completion information to the list of commands.
Add a function MR_trace_command_completion_info to access
that information.
runtime/mercury_wrapper.{c,h}
Add a runtime option `--force-readline', which tells mdb to
use readline even if MR_mdb_in is not a tty. This is needed
for tests/debugger/completion. `--force-readline' is not
documented because I'm not sure that it will work properly
in all situations (it's fine for the test).
Fix capitalisation in references to the Mercury User's Guide
in error messages.
trace/mercury_trace_readline.c:
Tell Readline to use our completer.
Handle `--force-readline'. Disable some Readline terminal
initialisation code which reports spurious warnings if the
input stream is not a tty.
trace/Mmakefile:
Add mercury_trace_completion.{c,h}.
runtime/mercury_array_macros.h:
Define a macro MR_find_first_match, which is like MR_bsearch
except that it finds the first match, not an arbitrary match.
runtime/mercury_memory.c:
Handle NULL pointers in MR_copy_string();
runtime/mercury_memory.h:
Add a macro MR_free_func which returns the address of free().
Used where it is necessary to pass the address of MR_free().
tests/debugger/Mmakefile:
tests/debugger/completion.m:
tests/debugger/completion.exp:
tests/debugger/completion.inp:
tests/debugger/completion.inputrc:
tests/debugger/completion.sub1.m:
tests/debugger/completion.sub2.m:
tests/debugger/completion.sub2.sub3.m:
Test case.