Files
mercury/tests/debugger/lval_desc_array.m
Zoltan Somogyi 74645f2293 Fix a bug that caused a core dump if the debugger attempted to look at stack
Estimated hours taken: 6
Branches: main

Fix a bug that caused a core dump if the debugger attempted to look at stack
frames with more than 64 live variables on the stack.

runtime/mercury_stack_layout.h:
	Fix a bug. The array of lval descriptors in a label layout structures
	has two components: the long descriptors and the short descriptors.
	The bug was that we were using an index with respect to the start
	of the first subarray to index into the second subarray. The fix is
	to subtract the length of the first subarray from the index first.
	(This problem rarely bit before because the first subarray's length
	is almost always zero.)

runtime/mercury_layout_util.c:
	Improve existing debugging code, but make its compilation conditional.
	The difference this makes in runtime is not significant for the
	debugger, but would be significant for native gc.

runtime/mercury_conf_param.h:
	Document the macro the debugging code is conditional on.

trace/mercury_trace_vars.c:
	Set unused fields of Var_Spec structures to explicitly invalid values,
	to avoid possible misinterpretation when using gdb.

tests/debugger/lval_desc_array.{m,inp,exp,exp2}:
	A regression test to check for the presence of the bug.

tests/debugger/Mmakefile:
	Enable the new test case.
2001-12-10 06:50:15 +00:00

50 lines
1.8 KiB
Mathematica

% This program tests whether the debugger is able to properly handle
% label layout structures which have variables whose locations (lvals)
% use long as well as short encodings.
:- module lval_desc_array.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module int.
main -->
{ A0 = 0 },
{ perform_increments(A0, A) },
io__write_int(A),
io__write_string("\n").
:- pred perform_increments(int::in, int::out) is det.
perform_increments -->
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment,
increment, increment, increment, increment, increment, increment.
:- pragma no_inline(increment/2).
:- pred increment(int::in, int::out) is det.
increment(N, N + 1).