[m-dev.] for review: centralizing variable names in the debugger

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Sep 18 15:18:13 AEDT 2000


For review by Mark.

Store the offsets leading to the names of variables in a central location.
Previously, each label layout included offsets for the variables live at that
label; now we store the offsets of variables in the proc layout. The new
data structure will soon be required by the declarative debugger for
displaying contours through representations of HLDS goals.

compiler/code_gen.m:
	Preserve the varset of every procedure for use by stack_layout.m.

compiler/continuation_info.m:
	Add a field to the cell from which proc layouts are derived to hold
	the varset.

compiler/stack_layout.m:
	Delete the offsets from label layouts and add them to proc layouts.
	The var name offsets array will always contain meaningful offsets
	for every variable that is live at a label with a label layout; with
	--trace-decl, it will also contain meaningful offsets for all the
	other variables in the procedure body.

runtime/mercury_stack_layout.h:
	Reflect the change in the types of the label and proc layout
	structures.

trace/mercury_trace.c:
trace/mercury_trace_vars.c:
	Look up variable names using the new location of the offsets leading to
	them.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.80
diff -u -r1.80 code_gen.m
--- compiler/code_gen.m	2000/09/04 22:33:26	1.80
+++ compiler/code_gen.m	2000/09/04 21:40:55
@@ -282,9 +282,10 @@
 		code_info__get_layout_info(InternalMap, CodeInfo, _),
 		code_util__make_local_entry_label(ModuleInfo, PredId, ProcId,
 			no, EntryLabel),
+		proc_info_varset(ProcInfo, VarSet),
 		ProcLayout = proc_layout_info(EntryLabel, Detism, TotalSlots,
 			MaybeSuccipSlot, MaybeTraceCallLabel, MaxTraceReg,
-			TraceSlotInfo, ForceProcId, InternalMap),
+			TraceSlotInfo, ForceProcId, VarSet, InternalMap),
 		global_data_add_new_proc_layout(GlobalData0,
 			proc(PredId, ProcId), ProcLayout, GlobalData1)
 	;
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.34
diff -u -r1.34 continuation_info.m
--- compiler/continuation_info.m	2000/09/04 22:33:33	1.34
+++ compiler/continuation_info.m	2000/09/04 21:40:57
@@ -89,6 +89,8 @@
 					% to be present, even if the option
 					% procid_stack_layout is not set?
 			need_proc_id	:: bool,
+					% The names of all the variables.
+			varset		:: prog_varset,
 					% Info for each internal label,
 					% needed for basic_stack_layouts.
 			internal_map	:: proc_label_layout_info
@@ -298,7 +300,7 @@
 :- implementation.
 
 :- import_module hlds_goal, code_util, type_util, inst_match, options.
-:- import_module string, require, varset, term.
+:- import_module string, require, term, varset.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.49
diff -u -r1.49 stack_layout.m
--- compiler/stack_layout.m	2000/09/04 22:33:50	1.49
+++ compiler/stack_layout.m	2000/09/11 03:33:41
@@ -72,6 +72,10 @@
 %				layout structure of the call event
 %	module layout		(MR_Module_Layout *) - points to the layout
 %				struct of the containing module.
+%	variable names		(int_least16_t *) - pointer to an array of
+%				offsets into the module-wide string table
+%	variable name count	(int_least16_t) - the number of offsets in the
+%				variable names array
 %	max reg at trace event	(int_least16_t) - the number of the highest
 %				numbered rN register live at a trace event
 %				inside the procedure
@@ -85,26 +89,40 @@
 %				stack slots used by the declarative debugger,
 %				if --trace-decl is set
 %
-% The first will point to the per-label layout info for the label associated
-% with the call event at the entry to the procedure. The purpose of this
-% information is to allow the runtime debugger to find out which variables
-% are where on entry, so it can reexecute the procedure if asked to do so
-% and if the values of the required variables are still available.
-% (If trace_stack_layout is not set, this field will be present,
+% The call trace info field will point to the label layout structure for the
+% label associated with the call event at the entry to the procedure. The
+% purpose of this information is to allow the runtime debugger to find out
+% which variables are where on entry, so it can reexecute the procedure if
+% asked to do so and if the values of the required variables are still
+% available. (If trace_stack_layout is not set, this field will be present,
 % but it will be set to NULL.)
 %
-% If the procedure is compiled with deep tracing, the fourth field will contain
-% a negative number. If it is compiled with shallow tracing, it will contain
-% the number of the stack slot that holds the flag that says whether this
-% incarnation of the procedure was called from deeply traced code or not.
+% The module layout field will point to the layout structure of the entire
+% module. Amongst other things, the string table for the module is stored
+% there. The variable names field points to an array that contains offsets
+% into the string table, with the offset at index i-1 giving the name of
+% variable i (since variable numbers start at one). If a variable has no name
+% or cannot be referred to from an event, the offset will be zero, at which
+% offset the string table will contain an empty string. The string table
+% is restricted to be small enough to be addressed with 16 bits;
+% a string is reserved near the start for a string that says "too many
+% variables". Stack_layout.m will generate a reference to this string
+% instead of generating an offset that does not fit into 16 bits.
+% Therefore using the stored offset to index into the string table
+% is always safe.
+%
+% If the procedure is compiled with deep tracing, the from full field will
+% contain a negative number. If it is compiled with shallow tracing, it will
+% contain the number of the stack slot that holds the flag that says whether
+% this incarnation of the procedure was called from deeply traced code or not.
 % (The determinism of the procedure decides whether the stack slot refers
 % to a stackvar or a framevar.)
 %
-% If --trace-decl is not set, the sixth field will contain a negative number.
-% If it is set, it will contain the number of the first of two stack slots
-% used by the declarative debugger; the other slot is the next higher numbered
-% one. (The determinism of the procedure decides whether the stack slot refers
-% to a stackvar or a framevar.)
+% If --trace-decl is not set, the maybe decl debug field will contain a
+% negative number. If it is set, it will contain the number of the first
+% of two stack slots used by the declarative debugger; the other slot is
+% the next higher numbered one. (The determinism of the procedure decides
+% whether the stack slot refers to a stackvar or a framevar.)
 %
 % If the option basic_stack_layout is set, we generate stack layout tables
 % for some labels internal to the procedure. This table will be stored in the
@@ -124,9 +142,9 @@
 % 	live data types locns 	(void *) - pointer to an area of memory
 %				containing information about where the live
 %				data items are and what their types are
-% 	live data names	 	(MR_Var_Name *) - pointer to vector of
-%				MR_Var_Name structs giving the HLDS var numbers
-%				as well as the names of live data items
+% 	live data var nums	(int_least16 *) - pointer to vector of ints
+%				giving the HLDS var numbers (if any) of live
+%				data items
 %	type parameters		(MR_Long_Lval *) - pointer to vector of
 %			 	MR_Long_Lval giving the locations of the
 %				typeinfos for the type parameters that may
@@ -169,23 +187,14 @@
 % The live data pair vector will have an entry for each live variable.
 % The entry will give the location of the variable and its type.
 %
-% The live data name vector pointer may be NULL. If it is not, the vector
-% will have an entry consisting of two 16-bit numbers for each live data item.
-% The first is the live data item's HLDS variable number, or one of two
+% The live data var nums vector pointer may be NULL. If it is not, the vector
+% will have an entry consisting of a 16-bit number for each live data item.
+% This is either the live data item's HLDS variable number, or one of two
 % special values. Zero means that the live data item is not a variable
 % (e.g. it is a saved copy of succip). The largest possible 16-bit number
 % on the other hand means "the number of this variable does not fit into
 % 16 bits". With the exception of these special values, the value in this
-% slot uniquely identifies the variable. The second 16-bit number is an offset
-% into the module-wide string table; the string at that offset is the
-% variable's name. If the variable or data item has no name, the offset
-% will be zero (at which offset one will find an empty string). The string
-% table is restricted to be small enough to be addressed with 16 bits;
-% a string is reserved near the start for a string that says "too many
-% variables". Stack_layout.m will generate a reference to this string
-% instead of generating an offset that does not fit into 16 bits.
-% Therefore using the stored offset to index into the string table
-% is always safe.
+% slot uniquely identifies the variable.
 %
 % If the number of type parameters is not zero, we store the number,
 % so that the code that needs the type parameters can materialize
@@ -256,7 +265,7 @@
 :- import_module hlds_data, hlds_pred, prog_data, prog_util, prog_out.
 :- import_module rtti, ll_pseudo_type_info, (inst), code_util.
 :- import_module assoc_list, bool, string, int, require.
-:- import_module map, term, set.
+:- import_module map, term, set, varset.
 
 %---------------------------------------------------------------------------%
 
@@ -276,6 +285,7 @@
 	globals__lookup_bool_option(Globals, trace_stack_layout, TraceLayout),
 	globals__lookup_bool_option(Globals, procid_stack_layout,
 		ProcIdLayout),
+	globals__lookup_bool_option(Globals, trace_decl, TraceDecl),
 	globals__have_static_code_addresses(Globals, StaticCodeAddr),
 	set_bbbtree__init(LayoutLabels0),
 
@@ -283,8 +293,9 @@
 	map__init(LabelTables0),
 	StringTable0 = string_table(StringMap0, [], 0),
 	LayoutInfo0 = stack_layout_info(ModuleName, CellCounter0,
-		AgcLayout, TraceLayout, ProcIdLayout, StaticCodeAddr,
-		[], [], LayoutLabels0, [], StringTable0, LabelTables0),
+		AgcLayout, TraceLayout, ProcIdLayout, TraceDecl,
+		StaticCodeAddr, [], [], LayoutLabels0, [],
+		StringTable0, LabelTables0, map__init),
 	stack_layout__lookup_string_in_table("", _, LayoutInfo0, LayoutInfo1),
 	stack_layout__lookup_string_in_table("<too many variables>", _,
 		LayoutInfo1, LayoutInfo2),
@@ -292,9 +303,9 @@
 		LayoutInfo2, LayoutInfo3),
 		% This version of the layout info structure is final in all
 		% respects except the cell count.
-	LayoutInfo3 = stack_layout_info(_, _, _, _, _, _, ProcLayouts,
+	LayoutInfo3 = stack_layout_info(_, _, _, _, _, _, _, ProcLayouts,
 		InternalLayouts, LayoutLabels, ProcLayoutArgs,
-		StringTable, LabelTables),
+		StringTable, LabelTables, _),
 	StringTable = string_table(_, RevStringList, StringOffset),
 	list__reverse(RevStringList, StringList),
 	stack_layout__concat_string_list(StringList, StringOffset,
@@ -342,9 +353,7 @@
 :- pred stack_layout__valid_proc_layout(proc_layout_info::in) is semidet.
 
 stack_layout__valid_proc_layout(ProcLayoutInfo) :-
-	ProcLayoutInfo = proc_layout_info(EntryLabel, _Detism,
-		_StackSlots, _SuccipLoc, _MaybeCallLabel, _MaxTraceReg,
-		_TraceSlotInfo, _ForceProcIdLayout, _InternalMap),
+	EntryLabel = ProcLayoutInfo ^ entry_label,
 	code_util__extract_proc_label_from_label(EntryLabel, ProcLabel),
 	(
 		ProcLabel = proc(_, _, DeclModule, Name, Arity, _),
@@ -537,54 +546,61 @@
 stack_layout__construct_layouts(ProcLayoutInfo) -->
 	{ ProcLayoutInfo = proc_layout_info(EntryLabel, Detism,
 		StackSlots, SuccipLoc, MaybeCallLabel, MaxTraceReg,
-		TraceSlotInfo, ForceProcIdLayout, InternalMap) },
-	stack_layout__construct_proc_layout(EntryLabel, Detism,
-		StackSlots, SuccipLoc, MaybeCallLabel, MaxTraceReg,
-		TraceSlotInfo, ForceProcIdLayout),
+		TraceSlotInfo, ForceProcIdLayout, VarSet, InternalMap) },
 	{ map__to_assoc_list(InternalMap, Internals) },
+	stack_layout__set_cur_proc_named_vars(map__init),
 	list__foldl(stack_layout__construct_internal_layout(EntryLabel),
 		Internals),
-	list__foldl(stack_layout__update_label_table, Internals).
+	stack_layout__get_cur_proc_named_vars(NamedVars),
+	stack_layout__get_label_tables(LabelTables0),
+	{ list__foldl(stack_layout__update_label_table, Internals,
+		LabelTables0, LabelTables) },
+	stack_layout__set_label_tables(LabelTables),
+	stack_layout__construct_proc_layout(EntryLabel, Detism,
+		StackSlots, SuccipLoc, MaybeCallLabel, MaxTraceReg,
+		TraceSlotInfo, ForceProcIdLayout, VarSet, NamedVars).
 
 %---------------------------------------------------------------------------%
 
 	% Add the given label to the module-wide label tables.
 
 :- pred stack_layout__update_label_table(pair(label, internal_layout_info)::in,
-	stack_layout_info::in, stack_layout_info::out) is det.
+	map(string, label_table)::in, map(string, label_table)::out) is det.
 
-stack_layout__update_label_table(Label - InternalInfo) -->
-	{ InternalInfo = internal_layout_info(Port, _, Return) },
+stack_layout__update_label_table(Label - InternalInfo,
+		LabelTables0, LabelTables) :-
+	InternalInfo = internal_layout_info(Port, _, Return),
 	(
-		{ Return = yes(return_layout_info(TargetsContexts, _)) },
-		{ stack_layout__find_valid_return_context(TargetsContexts,
-			Target, Context) }
+		Return = yes(return_layout_info(TargetsContexts, _)),
+		stack_layout__find_valid_return_context(TargetsContexts,
+			Target, Context)
 	->
-		{ Target = label(TargetLabel) ->
+		( Target = label(TargetLabel) ->
 			IsReturn = known_callee(TargetLabel)
 		;
 			IsReturn = unknown_callee
-		},
-		stack_layout__update_label_table_2(Label, Context, IsReturn)
+		),
+		stack_layout__update_label_table_2(Label, Context, IsReturn,
+			LabelTables0, LabelTables)
 	;
-		{ Port = yes(trace_port_layout_info(Context, _, _, _)) },
-		{ stack_layout__context_is_valid(Context) }
+		Port = yes(trace_port_layout_info(Context, _, _, _)),
+		stack_layout__context_is_valid(Context)
 	->
 		stack_layout__update_label_table_2(Label, Context,
-			not_a_return)
+			not_a_return, LabelTables0, LabelTables)
 	;
-		[]
+		LabelTables = LabelTables0
 	).
 
 :- pred stack_layout__update_label_table_2(label::in, context::in,
-	is_label_return::in, stack_layout_info::in, stack_layout_info::out)
-	is det.
+	is_label_return::in,
+	map(string, label_table)::in, map(string, label_table)::out) is det.
 
-stack_layout__update_label_table_2(Label, Context, IsReturn) -->
-	{ term__context_file(Context, File) },
-	{ term__context_line(Context, Line) },
-	stack_layout__get_label_tables(LabelTables0),
-	{ map__search(LabelTables0, File, LabelTable0) ->
+stack_layout__update_label_table_2(Label, Context, IsReturn,
+		LabelTables0, LabelTables) :-
+	term__context_file(Context, File),
+	term__context_line(Context, Line),
+	( map__search(LabelTables0, File, LabelTable0) ->
 		( map__search(LabelTable0, Line, LineInfo0) ->
 			LineInfo = [Label - IsReturn | LineInfo0],
 			map__det_update(LabelTable0, Line, LineInfo,
@@ -607,8 +623,7 @@
 			% We don't have a valid context for this label,
 			% so we don't enter it into any tables.
 		LabelTables = LabelTables0
-	},
-	stack_layout__set_label_tables(LabelTables).
+	).
 
 :- pred stack_layout__find_valid_return_context(
 	assoc_list(code_addr, prog_context)::in,
@@ -638,12 +653,12 @@
 
 :- pred stack_layout__construct_proc_layout(label::in, determinism::in,
 	int::in, maybe(int)::in, maybe(label)::in, int::in,
-	trace_slot_info::in, bool::in,
+	trace_slot_info::in, bool::in, prog_varset::in, map(int, string)::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__construct_proc_layout(EntryLabel, Detism, StackSlots,
 		MaybeSuccipLoc, MaybeCallLabel, MaxTraceReg, TraceSlotInfo,
-		ForceProcIdLayout) -->
+		ForceProcIdLayout, VarSet, UsedVarNames) -->
 	{
 		MaybeSuccipLoc = yes(Location0)
 	->
@@ -700,15 +715,14 @@
 
 	stack_layout__get_procid_stack_layout(ProcIdLayout0),
 	{ bool__or(ProcIdLayout0, ForceProcIdLayout, ProcIdLayout) },
-	(
-		{ ProcIdLayout = yes }
-	->
+	( { ProcIdLayout = yes } ->
 		{ code_util__extract_proc_label_from_label(EntryLabel,
 			ProcLabel) },
 		{ stack_layout__construct_procid_rvals(ProcLabel, IdRvals,
 			IdArgTypes) },
 		stack_layout__construct_trace_layout(MaybeCallLabel,
-			MaxTraceReg, TraceSlotInfo, TraceRvals, TraceArgTypes),
+			MaxTraceReg, TraceSlotInfo, VarSet, UsedVarNames,
+			TraceRvals, TraceArgTypes),
 		{ list__append(IdRvals, TraceRvals, IdTraceRvals) },
 		{ IdTraceArgTypes = initial(IdArgTypes, TraceArgTypes) }
 	;
@@ -731,16 +745,17 @@
 	stack_layout__add_proc_layout_data(CData, CDataName, EntryLabel).
 
 :- pred stack_layout__construct_trace_layout(maybe(label)::in, int::in,
-	trace_slot_info::in, list(maybe(rval))::out, create_arg_types::out,
+	trace_slot_info::in, prog_varset::in, map(int, string)::in,
+	list(maybe(rval))::out, create_arg_types::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__construct_trace_layout(MaybeCallLabel, MaxTraceReg,
-		TraceSlotInfo, Rvals, ArgTypes) -->
+		TraceSlotInfo, VarSet, UsedVarNameMap, Rvals, ArgTypes) -->
 	stack_layout__get_module_name(ModuleName),
 	stack_layout__get_trace_stack_layout(TraceLayout),
-	{
-		TraceLayout = yes
-	->
+	stack_layout__construct_var_name_vector(VarSet, UsedVarNameMap,
+		VarNameCount, VarNameVector),
+	{ TraceLayout = yes ->
 		( MaybeCallLabel = yes(CallLabel) ->
 			CallRval = yes(const(data_addr_const(
 					data_addr(ModuleName,
@@ -768,11 +783,12 @@
 		;
 			TrailRval = yes(const(int_const(-1)))
 		),
-		Rvals = [CallRval, ModuleRval,
-			MaxTraceRegRval, FromFullRval, TrailRval, DeclRval],
+		Rvals = [CallRval, ModuleRval, VarNameVector,
+			VarNameCount, MaxTraceRegRval,
+			FromFullRval, TrailRval, DeclRval],
 		ArgTypes = initial([
-			2 - yes(data_ptr),
-			1 - yes(int_least16),
+			3 - yes(data_ptr),
+			2 - yes(int_least16),
 			3 - yes(int_least8)],
 			none)
 	;
@@ -781,6 +797,61 @@
 		ArgTypes = initial([1 - yes(integer)], none)
 	}.
 
+:- pred stack_layout__construct_var_name_vector(prog_varset::in,
+	map(int, string)::in, maybe(rval)::out, maybe(rval)::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
+
+stack_layout__construct_var_name_vector(VarSet, UsedVarNameMap, Count, Vector)
+		-->
+	stack_layout__get_trace_decl(TraceDecl),
+	(
+		{ TraceDecl = yes },
+		{ varset__var_name_list(VarSet, VarNameList) },
+		{ list__map(stack_layout__convert_var_name_to_int,
+			VarNameList, VarNames) }
+	;
+		{ TraceDecl = no },
+		{ map__to_assoc_list(UsedVarNameMap, VarNames) }
+	),
+	(
+		{ VarNames = [FirstVar - _ | _] }
+	->
+		stack_layout__construct_var_name_rvals(VarNames, 1,
+			FirstVar, MaxVar, Rvals),
+		{ Count = yes(const(int_const(MaxVar))) },
+		stack_layout__get_cell_counter(C0),
+		{ counter__allocate(CNum, C0, C) },
+		stack_layout__set_cell_counter(C),
+		{ Reuse = no },
+		{ Vector = yes(create(0, Rvals, uniform(yes(uint_least16)),
+			must_be_static, CNum,
+			"stack_layout_var_names_vector", Reuse)) }
+	;
+		{ Count = yes(const(int_const(0))) },
+		{ Vector = yes(const(int_const(0))) }
+	).
+
+:- pred stack_layout__construct_var_name_rvals(assoc_list(int, string)::in,
+	int::in, int::in, int::out, list(maybe(rval))::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
+
+stack_layout__construct_var_name_rvals([], _CurNum, MaxNum, MaxNum, []) --> [].
+stack_layout__construct_var_name_rvals([Var - Name | VarNames1], CurNum,
+		MaxNum0, MaxNum, MaybeRvals) -->
+	( { Var = CurNum } ->
+		stack_layout__lookup_string_in_table(Name, Offset),
+		{ Rval = const(int_const(Offset)) },
+		{ MaxNum1 = Var },
+		{ VarNames = VarNames1 }
+	;
+		{ Rval = const(int_const(0)) },
+		{ MaxNum1 = MaxNum0 },
+		{ VarNames = [Var - Name | VarNames1] }
+	),
+	stack_layout__construct_var_name_rvals(VarNames, CurNum + 1,
+		MaxNum1, MaxNum, MaybeRvals1),
+	{ MaybeRvals = [yes(Rval) | MaybeRvals1] }.
+
 %---------------------------------------------------------------------------%
 
 :- pred stack_layout__construct_procid_rvals(proc_label::in,
@@ -1121,17 +1192,17 @@
 			rval,	% Rval describing the type of a live value.
 			llds_type, % The llds type of the rval describing the
 				% type.
-			rval,	% Rval describing the variable number of a
-				% live value. Always of llds uint_least16.
+			rval	% Rval describing the variable number of a
+				% live value. Always of llds type uint_least16.
 				% Contains zero if the live value is not
 				% a variable. Contains the hightest possible
 				% uint_least16 value if the variable number
 				% does not fit in 16 bits.
-			rval	% Rval describing the variable name of a
-				% live value. Always of llds uint_least16.
-				% Contains zero if the live value is not
-				% a variable, or if it is a variable with
-				% no name.
+	%		rval	% Rval describing the variable name of a
+	%			% live value. Always of llds type uint_least16.
+	%			% Contains zero if the live value is not
+	%			% a variable, or if it is a variable with
+	%			% no name.
 		).
 
 	% Construct a vector of (locn, live_value_type) pairs,
@@ -1142,7 +1213,7 @@
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__construct_liveval_arrays(VarInfos, LengthRval,
-		TypeLocnVector, NameVector) -->
+		TypeLocnVector, NumVector) -->
 	{ int__pow(2, stack_layout__short_count_bits, BytesLimit) },
 	stack_layout__construct_liveval_array_infos(VarInfos,
 		0, BytesLimit, IntArrayInfo, ByteArrayInfo),
@@ -1156,21 +1227,21 @@
 	{ LengthRval = const(int_const(EncodedLength)) },
 
 	{ SelectLocns = lambda([ArrayInfo::in, MaybeLocnRval::out] is det, (
-		ArrayInfo = live_array_info(LocnRval, _, _, _, _),
+		ArrayInfo = live_array_info(LocnRval, _, _, _),
 		MaybeLocnRval = yes(LocnRval)
 	)) },
 	{ SelectTypes = lambda([ArrayInfo::in, MaybeTypeRval::out] is det, (
-		ArrayInfo = live_array_info(_, TypeRval, _, _, _),
+		ArrayInfo = live_array_info(_, TypeRval, _, _),
 		MaybeTypeRval = yes(TypeRval)
 	)) },
 	{ SelectTypeTypes = lambda([ArrayInfo::in, CountTypeType::out] is det,(
-		ArrayInfo = live_array_info(_, _, TypeType, _, _),
+		ArrayInfo = live_array_info(_, _, TypeType, _),
 		CountTypeType = 1 - yes(TypeType)
 	)) },
-	{ AddRevNumsNames = lambda([ArrayInfo::in, NumNameRvals0::in,
-			NumNameRvals::out] is det, (
-		ArrayInfo = live_array_info(_, _, _, NumRval, NameRval),
-		NumNameRvals = [yes(NameRval), yes(NumRval) | NumNameRvals0]
+	{ AddRevNums = lambda([ArrayInfo::in, NumRvals0::in,
+			NumRvals::out] is det, (
+		ArrayInfo = live_array_info(_, _, _, NumRval),
+		NumRvals = [yes(NumRval) | NumRvals0]
 	)) },
 
 	{ list__map(SelectTypes, AllArrayInfo, AllTypes) },
@@ -1190,15 +1261,15 @@
 
 	stack_layout__get_trace_stack_layout(TraceStackLayout),
 	( { TraceStackLayout = yes } ->
-		{ list__foldl(AddRevNumsNames, AllArrayInfo,
-			[], RevVarNumNameRvals) },
-		{ list__reverse(RevVarNumNameRvals, VarNumNameRvals) },
+		{ list__foldl(AddRevNums, AllArrayInfo,
+			[], RevVarNumRvals) },
+		{ list__reverse(RevVarNumRvals, VarNumRvals) },
 		stack_layout__get_next_cell_number(CNum2),
-		{ NameVector = create(0, VarNumNameRvals,
+		{ NumVector = create(0, VarNumRvals,
 			uniform(yes(uint_least16)), must_be_static,
 			CNum2, "stack_layout_num_name_vector", Reuse) }
 	;
-		{ NameVector = const(int_const(0)) }
+		{ NumVector = const(int_const(0)) }
 	).
 
 :- pred stack_layout__construct_liveval_array_infos(list(var_info)::in,
@@ -1212,50 +1283,66 @@
 	{ VarInfo = var_info(Locn, LiveValueType) },
 	stack_layout__represent_live_value_type(LiveValueType, TypeRval,
 		TypeRvalType),
-	stack_layout__construct_liveval_name_rvals(VarInfo,
-		VarNumRval, VarNameRval),
+	stack_layout__construct_liveval_num_rval(VarInfo, VarNumRval),
 	(
 		{ BytesSoFar < BytesLimit },
 		{ stack_layout__represent_locn_as_byte(Locn, LocnByteRval) }
 	->
 		{ Var = live_array_info(LocnByteRval, TypeRval, TypeRvalType,
-			VarNumRval, VarNameRval) },
+			VarNumRval) },
 		stack_layout__construct_liveval_array_infos(VarInfos,
 			BytesSoFar + 1, BytesLimit, IntVars, ByteVars0),
 		{ ByteVars = [Var | ByteVars0] }
 	;
 		{ stack_layout__represent_locn_as_int(Locn, LocnRval) },
 		{ Var = live_array_info(LocnRval, TypeRval, TypeRvalType,
-			VarNumRval, VarNameRval) },
+			VarNumRval) },
 		stack_layout__construct_liveval_array_infos(VarInfos,
 			BytesSoFar, BytesLimit, IntVars0, ByteVars),
 		{ IntVars = [Var | IntVars0] }
 	).
 
-:- pred stack_layout__construct_liveval_name_rvals(var_info::in, rval::out,
-	rval::out, stack_layout_info::in, stack_layout_info::out) is det.
+:- pred stack_layout__construct_liveval_num_rval(var_info::in, rval::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__construct_liveval_name_rvals(var_info(_, LiveValueType),
-		VarNumRval, VarNameRval, SLI0, SLI) :-
+stack_layout__construct_liveval_num_rval(var_info(_, LiveValueType),
+		VarNumRval, SLI0, SLI) :-
 	( LiveValueType = var(Var, Name, _, _) ->
-		term__var_to_int(Var, VarNum0),
-			% The variable number has to fit into two bytes.
-			% We reserve the largest such number (Limit)
-			% to mean that the variable number is too large
-			% to be represented. This ought not to happen,
-			% since compilation would be glacial at best
-			% for procedures with that many variables.
-		Limit = (1 << (2 * stack_layout__byte_bits)) - 1,
-		int__min(VarNum0, Limit, VarNum),
+		stack_layout__convert_var_to_int(Var, VarNum),
 		VarNumRval = const(int_const(VarNum)),
-		stack_layout__lookup_string_in_table(Name, Offset, SLI0, SLI),
-		VarNameRval = const(int_const(Offset))
+		stack_layout__get_cur_proc_named_vars(NamedVars0, SLI0, SLI1),
+		( map__insert(NamedVars0, VarNum, Name, NamedVars) ->
+			stack_layout__set_cur_proc_named_vars(NamedVars,
+				SLI1, SLI)
+		;
+			% The variable has been put into the map already at
+			% another label.
+			SLI = SLI1
+		)
 	;
 		VarNumRval = const(int_const(0)),
-		VarNameRval = const(int_const(0)),
 		SLI = SLI0
 	).
 
+:- pred stack_layout__convert_var_name_to_int(pair(prog_var, string)::in,
+	pair(int, string)::out) is det.
+
+stack_layout__convert_var_name_to_int(Var - Name, VarNum - Name) :-
+	stack_layout__convert_var_to_int(Var, VarNum).
+
+:- pred stack_layout__convert_var_to_int(prog_var::in, int::out) is det.
+
+stack_layout__convert_var_to_int(Var, VarNum) :-
+	term__var_to_int(Var, VarNum0),
+		% The variable number has to fit into two bytes.
+		% We reserve the largest such number (Limit)
+		% to mean that the variable number is too large
+		% to be represented. This ought not to happen,
+		% since compilation would be glacial at best
+		% for procedures with that many variables.
+	Limit = (1 << (2 * stack_layout__byte_bits)) - 1,
+	int__min(VarNum0, Limit, VarNum).
+
 %---------------------------------------------------------------------------%
 
 	% The representation we build here should be kept in sync
@@ -1641,22 +1728,29 @@
 		agc_stack_layout	:: bool, % generate agc info?
 		trace_stack_layout	:: bool, % generate tracing info?
 		procid_stack_layout	:: bool, % generate proc id info?
+		trace_decl		:: bool, % declarative debugging?
 		static_code_addresses	:: bool, % have static code addresses?
 		proc_layouts		:: list(comp_gen_c_data),
 		internal_layouts	:: list(comp_gen_c_data),
 		label_set		:: set_bbbtree(label),
-					   % the set of labels (both entry
-					   % and internal) with layouts
+					   % The set of labels (both entry
+					   % and internal) with layouts.
 		proc_layout_args	:: list(maybe(rval)),
-					   % the list of proc_layouts in
+					   % The list of proc_layouts in
 					   % the module, represented as create
-					   % args
+					   % args.
 		string_table		:: string_table,
-		label_tables		:: map(string, label_table)
-					   % maps each filename that
+		label_tables		:: map(string, label_table),
+					   % Maps each filename that
 					   % contributes labels to this module
 					   % to a table describing those
 					   % labels.
+		cur_proc_named_vars	:: map(int, string)
+					   % Maps the number of each variable
+					   % in the current procedure whose
+					   % name is of interest in an internal
+					   % label's layout structure to the
+					   % name of that variable.
 	).
 
 :- pred stack_layout__get_module_name(module_name::out,
@@ -1674,6 +1768,9 @@
 :- pred stack_layout__get_procid_stack_layout(bool::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
+:- pred stack_layout__get_trace_decl(bool::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
+
 :- pred stack_layout__get_static_code_addresses(bool::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
@@ -1692,54 +1789,59 @@
 :- pred stack_layout__get_label_tables(map(string, label_table)::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__get_module_name(LI^module_name, LI, LI).
-stack_layout__get_cell_counter(LI^cell_counter, LI, LI).
-stack_layout__get_agc_stack_layout(LI^agc_stack_layout, LI, LI).
-stack_layout__get_trace_stack_layout(LI^trace_stack_layout, LI, LI).
-stack_layout__get_procid_stack_layout(LI^procid_stack_layout, LI, LI).
-stack_layout__get_static_code_addresses(LI^static_code_addresses, LI, LI).
-stack_layout__get_proc_layout_data(LI^proc_layouts, LI, LI).
-stack_layout__get_internal_layout_data(LI^internal_layouts, LI, LI).
-stack_layout__get_label_set(LI^label_set, LI, LI).
-stack_layout__get_string_table(LI^string_table, LI, LI).
-stack_layout__get_label_tables(LI^label_tables, LI, LI).
+:- pred stack_layout__get_cur_proc_named_vars(map(int, string)::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
 
+stack_layout__get_module_name(LI ^ module_name, LI, LI).
+stack_layout__get_cell_counter(LI ^ cell_counter, LI, LI).
+stack_layout__get_agc_stack_layout(LI ^ agc_stack_layout, LI, LI).
+stack_layout__get_trace_stack_layout(LI ^ trace_stack_layout, LI, LI).
+stack_layout__get_procid_stack_layout(LI ^ procid_stack_layout, LI, LI).
+stack_layout__get_trace_decl(LI ^ trace_decl, LI, LI).
+stack_layout__get_static_code_addresses(LI ^ static_code_addresses, LI, LI).
+stack_layout__get_proc_layout_data(LI ^ proc_layouts, LI, LI).
+stack_layout__get_internal_layout_data(LI ^ internal_layouts, LI, LI).
+stack_layout__get_label_set(LI ^ label_set, LI, LI).
+stack_layout__get_string_table(LI ^ string_table, LI, LI).
+stack_layout__get_label_tables(LI ^ label_tables, LI, LI).
+stack_layout__get_cur_proc_named_vars(LI ^ cur_proc_named_vars, LI, LI).
+
 :- pred stack_layout__add_proc_layout_data(comp_gen_c_data::in, data_name::in,
 	label::in, stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__add_proc_layout_data(NewProcLayout, NewDataName, NewLabel,
 		LI0, LI) :-
-	ProcLayouts0 = LI0^proc_layouts,
+	ProcLayouts0 = LI0 ^ proc_layouts,
 	ProcLayouts = [NewProcLayout | ProcLayouts0],
-	LabelSet0 = LI0^label_set,
+	LabelSet0 = LI0 ^ label_set,
 	set_bbbtree__insert(LabelSet0, NewLabel, LabelSet),
-	ModuleName = LI0^module_name,
+	ModuleName = LI0 ^ module_name,
 	NewProcLayoutArg = yes(const(data_addr_const(
 		data_addr(ModuleName, NewDataName)))),
-	ProcLayoutArgs0 = LI0^proc_layout_args,
+	ProcLayoutArgs0 = LI0 ^ proc_layout_args,
 	ProcLayoutArgs = [NewProcLayoutArg | ProcLayoutArgs0],
-	LI = (((LI0^proc_layouts := ProcLayouts)
-		^label_set := LabelSet)
-		^proc_layout_args := ProcLayoutArgs).
+	LI = (((LI0 ^ proc_layouts := ProcLayouts)
+		^ label_set := LabelSet)
+		^ proc_layout_args := ProcLayoutArgs).
 
 :- pred stack_layout__add_internal_layout_data(comp_gen_c_data::in,
 	label::in, stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__add_internal_layout_data(NewInternalLayout, NewLabel, LI0, LI) :-
-	InternalLayouts0 = LI0^internal_layouts,
+	InternalLayouts0 = LI0 ^ internal_layouts,
 	InternalLayouts = [NewInternalLayout | InternalLayouts0],
-	LabelSet0 = LI0^label_set,
+	LabelSet0 = LI0 ^ label_set,
 	set_bbbtree__insert(LabelSet0, NewLabel, LabelSet),
-	LI = ((LI0^internal_layouts := InternalLayouts)
-		^label_set := LabelSet).
+	LI = ((LI0 ^ internal_layouts := InternalLayouts)
+		^ label_set := LabelSet).
 
 :- pred stack_layout__get_next_cell_number(int::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_next_cell_number(CN, LI0, LI) :-
-	C0 = LI0^cell_counter,
+	C0 = LI0 ^ cell_counter,
 	counter__allocate(CN, C0, C),
-	LI = LI0^cell_counter := C.
+	LI = LI0 ^ cell_counter := C.
 
 :- pred stack_layout__set_cell_counter(counter::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
@@ -1749,10 +1851,15 @@
 
 :- pred stack_layout__set_label_tables(map(string, label_table)::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
+
+:- pred stack_layout__set_cur_proc_named_vars(map(int, string)::in,
+	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__set_cell_counter(CC, LI0, LI0^cell_counter := CC).
-stack_layout__set_string_table(ST, LI0, LI0^string_table := ST).
-stack_layout__set_label_tables(LT, LI0, LI0^label_tables := LT).
+stack_layout__set_cell_counter(CC, LI0, LI0 ^ cell_counter := CC).
+stack_layout__set_string_table(ST, LI0, LI0 ^ string_table := ST).
+stack_layout__set_label_tables(LT, LI0, LI0 ^ label_tables := LT).
+stack_layout__set_cur_proc_named_vars(NV, LI0,
+	LI0 ^ cur_proc_named_vars := NV).
 
 %---------------------------------------------------------------------------%
 
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.37
diff -u -r1.37 mercury_stack_layout.h
--- runtime/mercury_stack_layout.h	2000/08/03 06:18:54	1.37
+++ runtime/mercury_stack_layout.h	2000/09/11 03:41:53
@@ -248,8 +248,8 @@
 ** The last three fields are meaningful only if the MR_has_valid_var_count
 ** macro returns true.
 **
-** The names array pointer may be NULL, in which case no information about
-** variable names is available.
+** The var nums array pointer may be NULL, in which case no information about
+** variable numbers is available.
 **
 ** The type parameters array may also be NULL, but this means that there are
 ** no type parameters in the types of the variables live at this point.
@@ -258,9 +258,9 @@
 */
 
 typedef	struct MR_Stack_Layout_Vars_Struct {
-	MR_Integer			MR_slvs_var_count;
+	MR_Integer		MR_slvs_var_count;
 	void			*MR_slvs_locns_types;
-	MR_Var_Name		*MR_slvs_names;
+	MR_uint_least16_t	*MR_slvs_var_nums;
 	MR_Type_Param_Locns	*MR_slvs_tvars;
 } MR_Stack_Layout_Vars;
 
@@ -290,17 +290,6 @@
 		(((MR_uint_least8_t *)					    \
 			MR_end_of_long_desc_var_locns(slvs))[(i)])
 
-#define	MR_name_if_present(module_layout, vars, i)			    \
-		(((vars)->MR_slvs_names == NULL) ? "" :			    \
-		((module_layout)->MR_ml_string_table +			    \
-			(vars)->MR_slvs_names[(i)].MR_var_name_offset))
-
-#define	MR_name_if_present_from_label(label_layout, i)			    \
-		MR_name_if_present(					    \
-			(label_layout)->MR_sll_entry->MR_sle_module_layout, \
-			&((label_layout)->MR_sll_var_info),		    \
-			(i))
-
 /*-------------------------------------------------------------------------*/
 /*
 ** Definitions for MR_Stack_Layout_Entry
@@ -381,6 +370,8 @@
 				*MR_sle_call_label;
 	struct MR_Module_Layout_Struct
 				*MR_sle_module_layout;
+	MR_int_least16_t	*MR_sle_used_var_names;
+	MR_int_least16_t	MR_sle_max_var_num;
 	MR_int_least16_t	MR_sle_max_r_num;
 	MR_int_least8_t		MR_sle_maybe_from_full;
 	MR_int_least8_t		MR_sle_maybe_trail;
@@ -578,20 +569,20 @@
 */
 
 typedef struct MR_Module_File_Layout_Struct {
-	MR_String			MR_mfl_filename;
-	MR_Integer			MR_mfl_label_count;
+	MR_String		MR_mfl_filename;
+	MR_Integer		MR_mfl_label_count;
 	/* the following fields point to arrays of size MR_mfl_label_count */
 	MR_int_least16_t	*MR_mfl_label_lineno;
 	MR_Stack_Layout_Label	**MR_mfl_label_layout;
 } MR_Module_File_Layout;
 
 typedef	struct MR_Module_Layout_Struct {
-	MR_String			MR_ml_name;
-	MR_Integer			MR_ml_string_table_size;
+	MR_String		MR_ml_name;
+	MR_Integer		MR_ml_string_table_size;
 	char			*MR_ml_string_table;
-	MR_Integer			MR_ml_proc_count;
+	MR_Integer		MR_ml_proc_count;
 	MR_Stack_Layout_Entry	**MR_ml_procs;
-	MR_Integer			MR_ml_filename_count;
+	MR_Integer		MR_ml_filename_count;
 	MR_Module_File_Layout	**MR_ml_module_file_layout;
 } MR_Module_Layout;
 
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.25
diff -u -r1.25 mercury_trace.c
--- trace/mercury_trace.c	2000/08/08 04:58:37	1.25
+++ trace/mercury_trace.c	2000/09/01 13:39:10
@@ -438,7 +438,7 @@
 	for (i = 0; i < MR_all_desc_var_count(input_args); i++) {
 		arg_value = MR_trace_find_input_arg(event_info->MR_event_sll,
 				saved_regs,
-				input_args->MR_slvs_names[i].MR_var_num,
+				input_args->MR_slvs_var_nums[i],
 				&succeeded);
 
 		if (! succeeded) {
@@ -573,13 +573,13 @@
 	int				i;
 
 	vars = &label->MR_sll_var_info;
-	if (vars->MR_slvs_names == NULL) {
+	if (vars->MR_slvs_var_nums == NULL) {
 		*succeeded = FALSE;
 		return 0;
 	}
 
 	for (i = 0; i < MR_all_desc_var_count(vars); i++) {
-		if (var_num == vars->MR_slvs_names[i].MR_var_num) {
+		if (var_num == vars->MR_slvs_var_nums[i]) {
 			if (i < MR_long_desc_var_count(vars)) {
 				return MR_lookup_long_lval_base(
 					MR_long_desc_var_locn(vars, i),
Index: trace/mercury_trace_vars.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_vars.c,v
retrieving revision 1.21
diff -u -r1.21 mercury_trace_vars.c
--- trace/mercury_trace_vars.c	2000/08/03 06:19:30	1.21
+++ trace/mercury_trace_vars.c	2000/09/01 13:46:42
@@ -237,7 +237,6 @@
 	const MR_Stack_Layout_Label	*level_layout;
 	const MR_Stack_Layout_Entry	*entry;
 	const MR_Stack_Layout_Vars	*vars;
-	const MR_Var_Name		*var_info;
 	MR_Word				*valid_saved_regs;
 	int				var_count;
 	MR_TypeInfo			*type_params;
@@ -252,7 +251,7 @@
 	char				*s;
 	const char			*name;
 	const char			*string_table;
-	MR_Integer				string_table_size;
+	MR_Integer			string_table_size;
 	const char			*filename;
 	int				linenumber;
 
@@ -320,7 +319,7 @@
 		return NULL;
 	}
 
-	if (vars->MR_slvs_names == NULL) {
+	if (vars->MR_slvs_var_nums == NULL) {
 		return "there are no names for the live variables";
 	}
 
@@ -350,18 +349,27 @@
 
 	slot = 0;
 	for (i = 0; i < var_count; i++) {
-		var_info = &vars->MR_slvs_names[i];
+		int	var_num;
+		int	offset;
 
-		if (var_info->MR_var_num == 0) {
+		var_num = vars->MR_slvs_var_nums[i];
+
+		if (var_num == 0) {
 			/* this value is not a variable */
 			continue;
 		}
+
+		if (var_num > entry->MR_sle_max_var_num) {
+			MR_fatal_error("array bounds error on var name table");
+		}
 
-		if (var_info->MR_var_name_offset > string_table_size) {
+			/* variable number 1 is stored at offset 0 */
+		offset = entry->MR_sle_used_var_names[var_num - 1];
+		if (offset > string_table_size) {
 			MR_fatal_error("array bounds error on string table");
 		}
 
-		name = string_table + var_info->MR_var_name_offset;
+		name = string_table + offset;
 		if (name == NULL || streq(name, "")) {
 			/* this value is a compiler-generated variable */
 			continue;
@@ -379,8 +387,7 @@
 			continue;
 		}
 
-		MR_point.MR_point_vars[slot].MR_var_hlds_number =
-			var_info->MR_var_num;
+		MR_point.MR_point_vars[slot].MR_var_hlds_number = var_num;
 
 		copy = MR_copy_string(name);
 		MR_point.MR_point_vars[slot].MR_var_fullname = copy;
cvs diff: Diffing trax
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list