Files
mercury/tests/debugger/direct_arg_test.exp
Zoltan Somogyi 953ea7667f Fix deconstructing direct args.
The crash that this diff fixes occurred when giving a command such as
"print Var^1" to mdb, where the first argument of Var is a direct arg.

runtime/mercury_ml_expand_body.h:
    When deconstructing a term with a direct arg, return NULL
    as the value of expand_info->chosen_arg_word_sized_ptr.
    The crash occurred when we returned a non-null pointer,
    which violated the expectations of trace/mercury_trace_vars.c
    and its callers. (Not surprising, since those that function and
    its callers were written long before the direct_arg optimization
    was added to the system.)

runtime/mercury_deconstruct.h:
    Document the rationale behind the above changes. (The contents of
    mercury_ml_expand_body.h are #included in mercury_deconstruct.c.)

trace/mercury_trace_vars.c:
    Add the debugging code I used to track down this issue, in disabled form.

    Fix missing copyright year.

trace/mercury_trace_browse.c:
    Delete obsolete comment.

    Fix missing copyright years.

tests/debugger/direct_arg_test.{m,inp,exp}:
    A test case for this bug.

tests/debugger/Mmakefile:
    Enable the new test case.

compiler/hlds_out_type_table.m:
    When dumping out the data constructors in the type table,
    if a constructor has names for some of its fields,
    put the name and the type of each field on different lines.
    In the original test case for this bug, of which direct_arg_test.m
    is an extreme simplification, pretty much every line overflows
    without this.

    Also, factor out some duplicated code, and replace bools with values
    of a bespoke type.
2026-03-13 14:50:15 +11:00

19 lines
592 B
Plaintext

E1: C1 CALL pred direct_arg_test.main/2-0 (det) direct_arg_test.m:48
mdb> echo on
Command echo enabled.
mdb> context none
Contexts will not be printed.
mdb> register --quiet
mdb> break get_maybe_t
0: + stop interface pred direct_arg_test.get_maybe_t/1-0 (det)
mdb> continue
E2: C2 CALL pred direct_arg_test.get_maybe_t/1-0 (det)
mdb> finish
E3: C2 EXIT pred direct_arg_test.get_maybe_t/1-0 (det)
mdb> print MaybeT
MaybeT (arg 1) yes_t(t(1, 2, 43))
mdb> print MaybeT^1
MaybeT (arg 1)^1 t(1, 2, 43)
mdb> continue
yes_t(t(1, 2, 43))