[m-dev.] for review: handling layouts of compiler-generated procedures

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Feb 20 10:05:43 AEDT 1999


On 19-Feb-1999, Erwan Jahier <Erwan.Jahier at irisa.fr> wrote:
> Generalized the code in the external debugger in order to be able to handle
> inter-module inlining and compiler-generated procedures. To handle the former,
> I have added the definition module as a slot to the event structure. To handle
> the later, I have splitten output_current_slots() (and found_match()) in 2
> differents functions; one for user defined events, the other one for compiler
> generated events.

s/splitten/split/
s/in 2/into two/
s/differents/different/

Splitting output_current_slots is OK.
(If C had better support for discriminated unions,
then it would be better to keep it as a single
procedure and make one argument a discriminated
union of the stuff that differs between the two.
But C doesn't have good support for discriminated
unions, so splitting it up as you have done is probably
the best solution.)

However, splitting up found_match() in the way that you
have done is wrong -- it will not work.
In particular, the code will call error/1 (in found_match_comp)
whenever you get to an event for a compiler-generated procedure
while processing a forward_move_user request.

The simplest thing to do really would be to leave
the external debugger interface as it is, and for
trace/mercury_trace_external.c to just ignore all
events for compiler-generated procedures.

Alternatively, if you really want to support
events for compiler-generated procedures,
you should change the forward_move request to
look something like this:

	;	forward_move(
			match(event_number),
			match(call_number),
			match(depth_number),
			match(trace_port_type),
			match(pred_or_func),
			match(string),		% declaration module name
			match(string),		% definition module name
			pred_match,		
  			match(arity),
  			match(int),		% mode number

	:- type pred_match --->	
			% match user-defined preds only
			match_user_pred(match(string))		% predicate name
		;	
			% match compiler-generated preds only
			match_compiler_generated_pred(
				match(string),			% type name
				match(string),			% type module name
				match(string)			% type predicate name
			)
		;	
			% match either user-defined or compiler-generated preds
			match_any_pred(match(string)).		% predicate name
				
But this may not be worth the effort.

...
> @@ -217,7 +222,8 @@
>  		unix_address.sun_family = AF_UNIX;
>  		strcpy(unix_address.sun_path, unix_socket);
>  		addr = (struct sockaddr *) &unix_address;
> -		len = SUN_LEN(&unix_address);
> +		len = strlen(unix_address.sun_path) + 
> +			sizeof(unix_address.sun_family);
>  	} else {
>  		char hostname[255];
>  		char port_string[255];

That change is unrelated and therefore really ought to be
committed separately.

> +	if (MR_ENTRY_LAYOUT_COMPILER_GENERATED(layout->MR_sll_entry)) {
> +		MR_TRACE_CALL_MERCURY(
> +		    result = ML_DI_found_match_comp(
...
> +		    );
> +	} else {
> +		MR_TRACE_CALL_MERCURY(
> +		    result = ML_DI_found_match_user(
...
> +		    );
> +	}
>  	return result;
>  }

This code in mercury_trace_external.c is where you call found_match_comp
even though the current request is a forward_move_user request,
thus resulting in a call to error/1 from found_match_comp.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh>  |   but source code lives forever"
PGP: finger fjh at 128.250.37.3        |     -- leaked Microsoft memo.



More information about the developers mailing list