Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
.gitignore
.mgnuc_copts
.mgnuc_opts
.nocopyright
Mmakefile
README
RESERVED_MACRO_NAMES
mercury_event_parser.y
mercury_event_scanner.l
mercury_event_spec.c
mercury_event_spec.h
mercury_event_spec_missing.h
mercury_trace.c
mercury_trace.h
mercury_trace_alias.c
mercury_trace_alias.h
mercury_trace_browse.c
mercury_trace_browse.h
mercury_trace_cmd_backward.c
mercury_trace_cmd_backward.h
mercury_trace_cmd_breakpoint.c
mercury_trace_cmd_breakpoint.h
mercury_trace_cmd_browsing.c
mercury_trace_cmd_browsing.h
mercury_trace_cmd_dd.c
mercury_trace_cmd_dd.h
mercury_trace_cmd_developer.c
mercury_trace_cmd_developer.h
mercury_trace_cmd_exp.c
mercury_trace_cmd_exp.h
mercury_trace_cmd_forward.c
mercury_trace_cmd_forward.h
mercury_trace_cmd_help.c
mercury_trace_cmd_help.h
mercury_trace_cmd_misc.c
mercury_trace_cmd_misc.h
mercury_trace_cmd_parameter.c
mercury_trace_cmd_parameter.h
mercury_trace_cmd_queries.c
mercury_trace_cmd_queries.h
mercury_trace_cmd_table_io.c
mercury_trace_cmd_table_io.h
mercury_trace_cmds.h
mercury_trace_command_queue.c
mercury_trace_command_queue.h
mercury_trace_completion.c
mercury_trace_completion.h
mercury_trace_declarative.c
mercury_trace_declarative.h
mercury_trace_external.c
mercury_trace_external.h
mercury_trace_help.c
mercury_trace_help.h
mercury_trace_hold_vars.c
mercury_trace_hold_vars.h
mercury_trace_internal.c
mercury_trace_internal.h
mercury_trace_readline.c
mercury_trace_readline.h
mercury_trace_source.c
mercury_trace_source.h
mercury_trace_spy.c
mercury_trace_spy.h
mercury_trace_tables.c
mercury_trace_tables.h
mercury_trace_util.c
mercury_trace_util.h
mercury_trace_vars.c
mercury_trace_vars.h

README

This directory holds the trace subsystem,
i.e. the part of the Mercury debugger that is written in C code.


Notes on interfacing with other subsystems
------------------------------------------

If tracing is enabled, the compiler includes calls to MR_trace() in the
generated C code.  The trace subsystem in this directory is therefore
called directly from Mercury code, via MR_trace() in
runtime/mercury_trace_base.c.

One of the first things it does is to save the original values
of the Mercury registers in a variable called `saved_regs'.
The reason it needs to do this is that the code here may
modify registers, e.g. by allocating memory using incr_hp
or by calling Mercury code.  Once the original values of
the registers have been saved, the trace subsystem is free
to modify the Mercury registers.

So for all code in this directory, the usual convention is that the
original values of the Mercury registers are in `saved_regs',
while the current (scratch) values for the normal non-transient
Mercury registers etc. are in their normal locations, not in the
fake_reg copies, and the transient (register window) registers,
if any, are in the fake_reg copies.

Any code which uses macros such as incr_hp(), list_cons(),
make_aligned_string(), etc. that modify the heap pointer must call
restore_transient_regs() beforehand and must call save_transient_regs()
afterwards.  The simplest way to do this is to use the macro
MR_TRACE_USE_HP() in trace/mercury_trace_util.h.

The tracer may invoke Mercury code defined in the browser or library
directories if that code is exported to C using `pragma export'.
But any calls from functions here to code defined in Mercury
and exported using `pragma export', i.e. functions starting with `ML_'
prefixes, must be preceded by a call to save_registers() and
followed by a call to restore_registers().
The simplest way to do this is to use the macro
MR_TRACE_CALL_MERCURY() in trace/mercury_trace_util.h.