mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 06:14:59 +00:00
Estimated hours taken: 6
Branches: main
Fix some software rot that prevented I/O operations from working in mmos
grades. The problem was the change to the I/O module to make it use thread
local storage via a new field of the MR_Context structure which was accessed
via the MR_eng_this_context field of the engine, instead of via the
MR_eng_context field. The new field was not set by the code for initializing
the contexts used by own stack minimal model tabling.
runtime/mercury_context.h:
runtime/mercury_engine.h:
Add significant new documentation about how fields of the MR_Context
structure are accessed, both because the documentation is useful and to
make similar mistakes less likely in future.
Add a macro for use by own stack minimal model tabling.
runtime/mercury_thread.c:
Add a comment about a link to mercury_engine.h.
runtime/mercury_thread.h:
Convert to four-space indentation, and fix some formatting.
runtime/mercury_mm_own_stacks.c:
Add code for filling in the missing fields of newly created contexts.
runtime/mercury_wrapper.c:
In own stack minimal model grades, set up the main context properly.
The previous code was based on a flawed understanding of the
relationalship between MR_eng_context and MR_eng_this_context.
tests/debugger/mmos_print.{m,inp,exp}:
Add a new test case (which we don't yet pass due to a problem with
formatting of mdb output) to test the fix. The old versions of the
compiler don't pass this test case, because the "p *" commands of the
debugger invoke I/O code in the Mercury standard library, which fails
with a segfault due to the thread local fields of generators' contexts
being uninitialized.
Note that the .inp aborts execution, because without the abort the
execution would go into an infinite loop since mmos grades don't yet
have code for detecting completion.
tests/debugger/Mmakefile:
Enable the new test case in mmos grades.
Fix inconsistent indentation.
tests/tabling/Mmakefile:
Do not try to execute minimal tests in mmos grades, since we don't pass
them yet, and the symptom is in many cases an infinite loop.
24 lines
766 B
Plaintext
24 lines
766 B
Plaintext
1: 1 1 CALL pred mmos_print.main/2-0 (det) mmos_print.m:13
|
|
mdb> echo on
|
|
Command echo enabled.
|
|
mdb> register --quiet
|
|
mdb> print *
|
|
mdb: there are no live variables.
|
|
mdb> step
|
|
2: 2 2 CALL pred mmos_print.tc/2-0 (nondet) mmos_print.m:21
|
|
mdb> print *
|
|
A (arg 1) 1
|
|
mdb> step
|
|
tc(1) 1: 1 1 CALL pred mmos_print.GeneratorFor_tc/1-0 (nondet) mmos_print.m:21
|
|
mdb> print *
|
|
mdb: there are no live variables.
|
|
mdb> step
|
|
tc(1) 2: 2 2 CALL pred mmos_print.edge/2-0 (nondet) mmos_print.m:31 (mmos_print.m:22)
|
|
mdb> print *
|
|
HeadVar__1 1
|
|
mdb> step
|
|
tc(1) 3: 2 2 SWTC pred mmos_print.edge/2-0 (nondet) s1-na; mmos_print.m:31
|
|
mdb> print *
|
|
HeadVar__1 1
|
|
mdb> quit -y
|