[m-dev.] for review: a big step towards the trace-based debugger (part 2 of 3)

Tyson Dowd trd at stimpy.cs.mu.oz.au
Wed Apr 1 12:46:14 AEST 1998


On 20-Mar-1998, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> Index: compiler/stack_layout.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
> retrieving revision 1.9
> diff -u -r1.9 stack_layout.m
> --- stack_layout.m	1998/03/11 05:10:05	1.9
> +++ stack_layout.m	1998/03/18 00:56:23

> +% 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. (It also
> +% has room for its instantiation state, but this is not filled in yet.)
> +%
> +% The live data name vector pointer may be NULL. If it is not, the vector
> +% will have an entry for each live variable, with each entry being either
> +% NULL or giving the name of the variable.

In what cases will it be NULL?  What does that represent?

>  %
> -% -	the option trace_stack_layout is set, and the label represents
> -%	a traced event (with the current set of events, this means the
> -%	the entrance to one branch of a branched control structure)
> +% The number of type parameters is never stored as it is not needed --
> +% the type parameter vector will simply be indexed by the type variable's
> +% variable number stored within pseudo-typeinfos inside the elements
> +% of the live data pairs vectors. Since we allocate type variable numbers
> +% sequentially, the type parameter vector will usually be dense. However,

AND because the number of type variables is usually low 

> +	% Construct the layout describing a single internal label.
>  
>  :- pred stack_layout__construct_internal_layout(proc_label::in,
>  	pair(label, internal_layout_info)::in,
> @@ -326,74 +321,40 @@
>  	stack_layout__get_module_name(ModuleName),
>  	{ EntryAddrRval = const(data_addr_const(data_addr(ModuleName,
>  		stack_layout(local(ProcLabel))))) },
> -
> -	stack_layout__construct_agc_rvals(Internal, AgcRvals),
> -
> -	{ LayoutRvals = [yes(EntryAddrRval) | AgcRvals] },
> -
> +	{ Label = local(_, LabelNum0) ->
> +		LabelNum = LabelNum0
> +	;
> +		LabelNum = -1
> +	},

In what cases would LabelNum = -1 happen (operationally)?
Should be documented, along with how the runtime should interpret this
data.  Should be documented above too (I don't remember seeing it, but
I could be wrong).

> Index: runtime/mercury_stack_layout.h
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
> retrieving revision 1.2
> diff -u -r1.2 mercury_stack_layout.h
> --- mercury_stack_layout.h	1998/03/11 22:07:30	1.2
> +++ mercury_stack_layout.h	1998/03/18 05:05:54
> @@ -10,6 +10,10 @@
>  /*
>  ** mercury_stack_layout.h -
>  **	Definitions for the stack layout data structures. 
> +**
> +** NOTE: The constants and data-structures used here need to be kept in
> +** sync with the ones generated in the compiler. If you change anything here,
> +** you may need to change compiler/stack_layout.m as well.
>  */
>  
>  /*
> @@ -49,7 +53,8 @@
>  
>  #define MR_DETISM_FIRST_SOLN(d)		(((d) & 8) != 0)
>  
> -#define MR_DETISM_DET_CODE_MODEL(d)	(((d) & 1) == 0)
> +#define MR_DETISM_DET_CODE_MODEL(d)	(!MR_DETISM_AT_MOST_MANY(d) \
> +					|| MR_DETISM_FIRST_SOLN(d))
>  

But MR_DETISM_FIRST_SOLN is actually subsumed by !MR_DETISM_AT_MOST_MANY
isn't it?  FIRST_SOLN merely checks whether we are *explicitly* in a
committed choice environement.

>  /*
>  ** Definitions for "MR_Live_Lval"
> @@ -112,7 +117,7 @@
>  ** The data is encoded such that low values (less than
>  ** TYPELAYOUT_MAX_VARINT) represent succip, hp, etc.  Higher values
>  ** represent data variables, and are pointers to a 2 word cell, 
> -** containing a type_info and an instantiation represention.
> +** containing a pseudo type_info and an instantiation represention.
>  **
>  ** This data is generated in compiler/stack_layout.m, which must be kept
>  ** in sync with the constants defined here.
> @@ -130,7 +135,7 @@
>  } MR_Lval_NonVar;
>  
>  typedef struct { 
> -	Word	type;	/* contains a type_info */
> +	Word	*pseudo_type_info;
>  	Word	inst;	/* not yet used; currently always -1 */
>  } MR_Var_Shape_Info;
>  
> @@ -140,10 +145,10 @@
>  		((MR_Lval_NonVar) T)
>  
>  #define MR_LIVE_TYPE_GET_VAR_TYPE(T)   			\
> -		((Word) ((MR_Var_Shape_Info *) T)->type)
> +		(((MR_Var_Shape_Info *) T)->pseudo_type_info)
>  
>  #define MR_LIVE_TYPE_GET_VAR_INST(T)   			\
> -		((Word) ((MR_Var_Shape_Info *) T)->inst)
> +		(((MR_Var_Shape_Info *) T)->inst)
>  
>  /*
>  ** Macros to support hand-written C code.
> @@ -151,9 +156,10 @@
>  
>  /*
>  ** Define a stack layout for a label that you know very little about.
> -** It's just a generic entry label, no useful information, except
> +** It is just a generic entry label, no useful information, except
>  ** the code address for the label.
>  */ 
> +
>  #ifdef MR_USE_STACK_LAYOUTS
>   #define MR_MAKE_STACK_LAYOUT_ENTRY(l) 					\
>   const struct mercury_data__stack_layout__##l##_struct {		\
> @@ -178,6 +184,7 @@
>  ** The only useful information in this structure is the code address
>  ** and the reference to the entry for this label.
>  */ 
> +
>  #ifdef MR_USE_STACK_LAYOUTS
>   #define MR_MAKE_STACK_LAYOUT_INTERNAL_WITH_ENTRY(l, e)			\
>   const struct mercury_data__stack_layout__##l##_struct {		\
> @@ -208,6 +215,7 @@
>  ** The only useful information in this structure is the code address
>  ** and the reference to the entry for this label.
>  */ 
> +
>  #ifdef MR_USE_STACK_LAYOUTS
>   #define MR_MAKE_STACK_LAYOUT_INTERNAL(e, x)				\
>   const struct mercury_data__stack_layout__##e##_i##x##_struct {		\
> @@ -227,18 +235,25 @@
>  ** Structs and macros to support stack layouts.
>  */
>  
> -typedef	struct MR_stack_layout_var_struct {
> +typedef	struct MR_Stack_Layout_Var_Struct {
>  	MR_Live_Lval		MR_slv_locn;
>  	MR_Live_Type		MR_slv_live_type;
> -} MR_stack_layout_var;
> +} MR_Stack_Layout_Var;
>  
> -typedef	struct MR_stack_layout_vars_struct {
> -	MR_stack_layout_var	*MR_slvs_pairs;
> +typedef	struct MR_Stack_Layout_Vars_Struct {
> +	MR_Stack_Layout_Var	*MR_slvs_pairs;
>  	String			*MR_slvs_names;
> -	Word			*MR_slvs_tvars;
> -} MR_stack_layout_vars;
> +	Integer			MR_slvs_tvar_count;
> +	MR_Live_Lval		*MR_slvs_tvars;
> +} MR_Stack_Layout_Vars;
> +
> +#define	MR_name_if_present(vars, i)					\
> +				((vars->MR_slvs_names != NULL		\
> +				&& vars->MR_slvs_names[(i)] != NULL)	\
> +				? vars->MR_slvs_names[(i)]		\
> +				: "")
>  
> -typedef	struct MR_stack_layout_entry_struct {
> +typedef	struct MR_Stack_Layout_Entry_Struct {
>  	Code			*MR_sle_code_addr;
>  	MR_Determinism		MR_sle_detism;
>  	Integer			MR_sle_stack_slots;
> @@ -251,18 +266,17 @@
>  	Integer			MR_sle_arity;
>  	Integer			MR_sle_mode;
>  	/* the fields from here onwards are present only with trace layouts */
> -	Integer			MR_sle_in_arg_count;
> -	MR_stack_layout_vars	MR_sle_in_arg_info;
> -	Integer			MR_sle_out_arg_count;
> -	MR_stack_layout_vars	MR_sle_out_arg_info;
> -} MR_stack_layout_entry;
> -
> -typedef	struct MR_stack_layout_label_struct {
> -	MR_stack_layout_entry	*MR_sll_entry;
> +	struct MR_Stack_Layout_Label_Struct
> +				*MR_sle_call_label;
> +} MR_Stack_Layout_Entry;
> +
> +typedef	struct MR_Stack_Layout_Label_Struct {
> +	MR_Stack_Layout_Entry	*MR_sll_entry;
> +	Integer			MR_sll_label_num;
>  	Integer			MR_sll_var_count;
>  	/* the last field is present only if MR_sll_var_count > 0 */
> -	MR_stack_layout_vars	MR_sll_var_info;
> -} MR_stack_layout_label;
> +	MR_Stack_Layout_Vars	MR_sll_var_info;
> +} MR_Stack_Layout_Label;
>  
>  /* The following macros support obsolete code. */
>  #define MR_ENTRY_STACK_LAYOUT_GET_LABEL_ADDRESS(s)		\
> @@ -282,4 +296,3 @@
>  
>  /*---------------------------------------------------------------------------*/
>  #endif /* not MERCURY_STACK_LAYOUT_H */
> -
> Index: runtime/mercury_stack_trace.c
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
> retrieving revision 1.2
> diff -u -r1.2 mercury_stack_trace.c
> --- mercury_stack_trace.c	1998/03/16 12:23:37	1.2
> +++ mercury_stack_trace.c	1998/03/20 08:11:17
> @@ -17,13 +17,12 @@
>  void
>  MR_dump_stack(Code *success_pointer, Word *det_stack_pointer)
>  {
> -	Label *label;
> -	MR_Live_Lval location;
> -	MR_stack_layout_label *layout;
> -	MR_stack_layout_entry *entry_layout;
> -	MR_Lval_Type type;
> -	int number, determinism;
> -
> +	Label			*label;
> +	MR_Live_Lval		location;
> +	MR_Stack_Layout_Label	*layout;
> +	MR_Stack_Layout_Entry	*entry_layout;
> +	MR_Lval_Type		type;
> +	int			number, determinism;
>  
>  #ifndef MR_STACK_TRACE
>  	fprintf(stderr, "Stack dump not available in this grade.\n");
> @@ -36,7 +35,7 @@
>  			fatal_error("internal label not found");
>  		}
>  
> -		layout = (MR_stack_layout_label *) label->e_layout;
> +		layout = (MR_Stack_Layout_Label *) label->e_layout;
>  		entry_layout = layout->MR_sll_entry;
>  		
>  		label = lookup_label_addr(
> @@ -65,4 +64,3 @@
>  	} while (MR_DETISM_DET_CODE_MODEL(determinism));
>  #endif /* MR_STACK_TRACE */
>  }
> -
> --------------------------------------------------------------------------
> 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
> --------------------------------------------------------------------------

-- 
       Tyson Dowd           # So I asked Sarah: what's the serial number on
                            # your computer? She replied:
     trd at cs.mu.oz.au        #          A-C-2-4-0-V-/-5-0-H-Z
http://www.cs.mu.oz.au/~trd #



More information about the developers mailing list